-
Notifications
You must be signed in to change notification settings - Fork 45.6k
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
Replace passive effect context with boolean #18309
Replace passive effect context with boolean #18309
Conversation
@@ -299,6 +298,10 @@ let spawnedWorkDuringRender: null | Array<ExpirationTime> = null; | |||
// receive the same expiration time. Otherwise we get tearing. | |||
let currentEventTime: ExpirationTime = NoWork; | |||
|
|||
// Dev only flag that tracks if passive effects are currently being flushed. | |||
// We warn about state updates for unmounted components differently in this case. | |||
let isFlushingPassiveEffects = false; |
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.
Preference on the name? (I have none.)
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 c2aafa7:
|
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.
Looks good to me, as does the naming.
@@ -2448,6 +2454,10 @@ function flushPassiveEffectsImpl() { | |||
nestedPassiveUpdateCount = | |||
rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; | |||
|
|||
if (__DEV__) { | |||
isFlushingPassiveEffects = false; |
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.
Do we have a guarantee code in between wouldn't throw even if user code throws (unless there's a bug in React)?
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.
User code is try/catched.
Though I wonder if I should have moved this before flushSyncCallbackQueue
since that's where we reset prev exceution context.
Follow up to #18307