-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change .forceUpdate() to participate in the update queue #1939
Conversation
Out of interest, do you (or anyone else) know how this behavior compares to React in its various rendering modes (normal, batched, concurrent etc.)? |
I haven't compared the various render modes of React specifically, but I can confirm that they schedule |
@robertknight @marvinhagemeister yes I think this is somewhat analogous to batched mode. Certainly in name, the change here enables batching of forceUpdate, meaning the only way to produce a non-batched update is now a top-level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great all failing tests should be resolved by rerender
addition in the tests. analogue to #1892 (might be able to cherry pick)
@developit Awesome, also +1 on the additional tree-shaking benefits :) Now we just need to pass the failing tests and then we're good to go 🎉 |
@JoviDeCroock Good catch! I went ahead and added all missing There |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super awesome! This makes it a lot easier for the devtools to measure commits and other things. Love it 💯 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to change the setter in useReducer to forceUpdate now instead of setState({}) might save some bytes too
@JoviDeCroock just checked: Using |
This changes forceUpdate so that it's no longer inherently synchronous, instead pushing updates into the same queue currently used for state.
This means the following produces a single render pass:
I left a commented-out possible tweak that would still allow standalone forceUpdate() to be synchronous when nothing else is in the queue, but I'm not sure that's desirable.