-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Initialize update queue object on mount #17560
Conversation
e6eb323
to
f2d73ef
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7768843:
|
Details of bundled changes.Comparing: e039e69...7768843 react-dom
react-native-renderer
react-test-renderer
react-noop-renderer
react-art
react-reconciler
ReactDOM: size: 0.0%, gzip: 0.0% Size changes (experimental) |
Fixes a bug related to rebasing updates. Once an update has committed, it should never un-commit, even if interrupted by a higher priority update. The fix includes a refactor of how update queues work. This commit is a combination of two PRs: - facebook#17483 by @sebmarkbage refactors the hook update queue - facebook#17510 by @acdlite refactors the class and root update queue Landing one without the other would cause state updates to sometimes be inconsistent across components, so I've combined them into a single commit in case they need to be reverted. Co-authored-by: Sebastian Markbåge <[email protected]> Co-authored-by: Andrew Clark <[email protected]>
Instead of lazily initializing update queue objects on the first update, class and host root queues are created on mount. This simplifies the logic for appending new updates and matches what we do for hooks.
Details of bundled changes.Comparing: e039e69...7768843 react-reconciler
react-noop-renderer
react-dom
react-art
react-test-renderer
react-native-renderer
ReactDOM: size: -0.5%, gzip: -0.1% Size changes (stable) |
f2d73ef
to
7768843
Compare
I don't think this should be on |
That makes sense but I didn't want to deal with the ramifications of other stuff that reads from it. Like DevTools. At least right now. |
Basically I'm trying to keep the scope of this "bugfix" somewhat narrow. Can do a fuller refactor later. |
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.
curious about the need for additional not-null check 🤔
' '.repeat(depth + 1) + '~', | ||
'[' + update.expirationTime + ']', | ||
); | ||
} while (update !== null && update !== first); |
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.
Can update
be changed while inside the loop? Do we need to additionally check for not null being inside if (update !== null)
?
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.
Good catch. It's missing a update = update.next
line at the end of the loop. Honestly I don't think anyone actually uses this method anymore, so I'll probably just remove 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.
Yeah, I believe removal would be safe here and in the block below.
' '.repeat(depth + 1) + '~', | ||
'[' + pendingUpdate.expirationTime + ']', | ||
); | ||
} while (pendingUpdate !== null && pendingUpdate !== firstPending); |
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.
Same question whether pendingUpdate needs to be checked for ! == null
when already inside if
check
Follow-up to b617db3
Instead of lazily initializing update queue objects on the first update, class and host root queues are created on mount. This simplifies the logic for appending new updates and matches what we do for hooks.