-
Notifications
You must be signed in to change notification settings - Fork 46.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
Decouple dispatching from attemptToDispatchEvent #22851
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gaearon
changed the title
Decoupled dispatching from attemptToDispatchEvent
Decouple dispatching from attemptToDispatchEvent
Dec 1, 2021
facebook-github-bot
added
the
React Core Team
Opened by a member of the React Core Team
label
Dec 1, 2021
Comparing: ca106a0...905ab99 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
gaearon
force-pushed
the
decouple-ret
branch
2 times, most recently
from
December 1, 2021 23:52
9b7dd48
to
6bcc386
Compare
gaearon
commented
Dec 2, 2021
// Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. | ||
export function attemptToDispatchEvent( | ||
export let return_shouldDispatch = false; | ||
export let return_targetInst = 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.
Technically this leaks at module level but next event will clear it. So it's fine.
It is unnecessary because it's only true when retval is null.
salazarm
approved these changes
Dec 2, 2021
zhengjitf
pushed a commit
to zhengjitf/react
that referenced
this pull request
Apr 15, 2022
* Decoupled dispatching from attemptToDispatchEvent * Remove unnecessary field It is unnecessary because it's only true when retval is null.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purely refactoring, no functional changes.
We need to split up dispatching from finding the blocked instance, so that we can apply different logic in each case (e.g. replay instead of dispatching through the event system). In #22680 we tried to do this via a special return type, but it's really noisy and I find it difficult to verify the existing behavior is intact. This is an alternative proposal, where we just use a few fields as makeshift "return values" to avoid allocating. I think I've seen this somewhere in the code. (I mean, we could also just use a tuple but idk if this is controversial for some reason.)
If we land this I think we can make #22680 simpler and more self-contained.