Bug: transition update after sync update calculate state wrong

This issue has been created since 2022-11-05.

here is the demo code: https://codesandbox.io/s/transitionpuzzle-ekxdx7

react version: 18.2.0

from my perspective, I start a transition-level update and a sync-level update in a click callback, first the count is updated to 1, it is reasonable, but after this update, the count is updated to 3, why, should't it be updated to 2, as it should replace the previous value.

I traced down the react source code, found that in the transition update, the 'newState' is updated to 2, and then update find a next update which is the count => count + 1, I don't understand why this completed update is still in the updateQueue?

I thought it should be a bug? If not, please help me why this happens, there must be somehing I'm missing, thanks in advance.

NaNshekhar04 wrote this answer on 2022-11-06

Hey @Josscii ! NEI !! Is this the problem you were facing ? Your previous state with the startTransition was not updating to the state you were setting onClick !

I have Fixed some part of your code if this was something you were searching for than here is the link to my sandbox you can refer and let me know was this the same you were trying to do !

Here is the link :- https://codesandbox.io/s/transitionpuzzle-forked-lcu9yw?file=/src/App.js

Thank You !

Josscii wrote this answer on 2022-11-06

@NaNshekhar04 Sorry, I don't think we are talking about the same thing, thanks for your reply.

Josscii wrote this answer on 2022-11-14

it's not a bug, it's just how react works, when react skip a update, while this skiped update begin, it will calculate the updates behind it again.

More Details About Repo
Owner Name facebook
Repo Name react
Full Name facebook/react
Language JavaScript
Created Date 2013-05-24
Updated Date 2022-12-10
Star Count 198882
Watcher Count 6638
Fork Count 41302
Issue Count 1120

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Screen reader doesn't announce first result 2 2020-08-21 2022-12-03
Handle conflicting autofix instructions 12 2022-11-08 2022-12-03
Lack of words in one category 1 2022-05-17 2022-11-20
AutoSave causes lag due to many changes coming from INotifyPropertyChanged/INotifyCollectionChanged 0 2021-04-30 2022-07-02
Report paths of the process names 1 2021-07-19 2022-10-26
SHA Sum to verify the cloned repo with the list of domain names. 0 2021-07-19 2022-10-26
Contour map plots as linked views 0 2022-03-05 2022-07-02
laissebaiser.com - design is broken 1 2022-03-09 2022-08-26
[documentation] Continous update 5 2021-12-31 2022-09-21
README discord link seems to be broken? 2 2021-12-30 2022-10-31
Account Provisioning Customizations and Global/Account Customizations Concurrency Question/Bug? 2 2022-05-12 2022-11-05
How to reduce "batch size" to save memory 2 2022-09-05 2022-10-31
Remove uncss? 10 2021-10-08 2022-01-10
Add search to docs 4 2021-07-22 2022-01-18
Program freezes when order is timed out. 1 2021-04-18 2022-11-13
video clicked in related content does not play 1 2022-02-19 2022-10-20
Warning Sequence not in vcf.gz, leading to no variant applied 4 2022-09-25 2022-11-26
Trudesk Self-Hosted Docs are out-of-date 10 2020-04-17 2022-11-05
FAIL tests/test-slirp4netns-seccomp.sh (`unshare failed: Operation not permitted`) 2 2022-10-19 2022-12-02
[Feature Request] Notes 2 2021-04-14 2022-11-27
Crash on world load 1.17.1 6 2021-11-27 2022-10-21
[Link transaction] Duplicate text in dropdown 'this transaction' 1 2022-01-04 2022-11-02
default dictionary for template substitution costs missing some gates 0 2022-01-26 2022-10-26
Please consider installing the executable into bin/ on UNIX-like systems 2 2022-06-20 2022-12-02
Store on a repository ignores the $fillable on the Model 1 2022-06-07 2022-11-20
Bugfix :: Debugger error indicator badge misaligned 5 2022-03-18 2022-10-15
Brand colors for 'add datasource button' 2 2021-12-21 2022-11-18
Impossible to seek under macOS Monterey 0 2022-11-03 2022-11-05
希望增加Oracle Cloud的OSS存储 0 2021-12-26 2022-11-08
[Bug] Komga extension wrong region label 9 2021-10-03 2022-10-22
[Training module] Communications 0 2022-01-12 2022-10-11
Point should not be awarded in #bot-spam-playground 3 2021-04-16 2022-12-07
Encoding value classes and mapping type fields to snakeCase 0 2021-08-09 2022-11-30
Look for efs_id for tag 0 2022-08-12 2022-11-28
Improve the Save icon 4 2022-08-24 2022-11-27
Broken link on homepage 4 2021-12-03 2022-12-02
[BUG] PTBSQLAlchemyJobStore can't handle conversation timeout jobs 1 2021-11-11 2022-11-19
DHO-5: Create playbook to setup for a test environment 0 2021-04-26 2022-11-12
Support for USDT probes 2 2022-02-22 2022-11-27
Don't deploy the jumbox when using a deployer machine 0 2021-09-08 2022-11-21
make downloading txsets more efficient 0 2022-03-29 2022-11-07
Saving checkpoints during training and loading 3 2021-02-10 2022-12-09
Usage drops in Nvidia GPU causes massive frame drops. 0 2019-12-30 2022-11-27
Blocking/looping script 11 2021-10-12 2022-11-26
C++ operator== fails for native inline types 5 2021-12-17 2022-10-27
How to get around max size of 2GB for very big sequential objects? 4 2022-07-22 2022-09-02
CUDA HAL needs to manage the active context. 13 2022-06-02 2022-11-09
Is Consume thread safe? 1 2021-11-29 2022-10-26
Failed to build RiderLink plugin 3 2022-01-11 2022-11-26
reCAPTCHA removes form #id from success URL 0 2022-01-27 2022-11-18