-
Notifications
You must be signed in to change notification settings - Fork 49k
Split recent passive effects changes into 2 flags #18030
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
Conversation
Separate flags can now be used to opt passive effects into: 1) Deferring destroy functions on unmount to subsequent passive effects flush 2) Running all destroy functions (for all fibers) before create functions This allows us to test the less risky feature (2) separately from the more risky one.
6d0aace
to
15c91fc
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 5897bd4:
|
packages/shared/ReactFeatureFlags.js
Outdated
// Controls behavior of deferred effect destroy functions during unmount. | ||
// Previously these functions were run during commit (along with layout effects). | ||
// Ideally we should delay these until after commit for performance reasons. | ||
// This flag provides a killswitch if that proves to break existing code somehow. | ||
// | ||
// WARNING Only enable this flag in conjunction with runAllPassiveEffectDestroysBeforeCreates. |
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 constraint is a little gross
Unit tests failures in ReactHooksWithNoopRenderer
and ReactSuspenseWithNoopRenderer
will prevent us from accidentally using an invalid combination.
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.
Instead of two booleans you could use an enum, to prevent the invalid combination
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.
True. I considered that but our precedent has always been booleans for flags.
I don't feel strongly about this though.
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.
Alternative, in the code, you could also check for both booleans before you enable the "defer unmounts" feature.
Just want to make it harder for someone to accidentally toggle the wrong combination of GKs.
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 hear you. That seems reasonable.
Details of bundled changes.Comparing: 58b8797...5897bd4 react
react-art
react-dom
scheduler
react-reconciler
Size changes (stable) |
Details of bundled changes.Comparing: 58b8797...5897bd4 react
react-dom
react-reconciler
scheduler
react-art
Size changes (experimental) |
…eEffectDestroysBeforeCreates is true
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.
Reviewed with w=1, looks good to me!
act = ReactNoop.act; | ||
} | ||
|
||
[true, false].forEach(deferPassiveEffectCleanupDuringUnmount => { |
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.
wow function
much pure
Separate flags can now be used to opt passive effects into:
deferPassiveEffectCleanupDuringUnmount
: Defer passive effect destroy functions on unmount to subsequent passive effects flush. (FlushuseEffect
clean up functions in the passive effects phase #17925)runAllPassiveEffectDestroysBeforeCreates
: Running all passive effect destroy functions (for all fibers) before create functions. (Flush all passive destroy fns before calling create fns #17947)This allows us to test the less risky feature (#17947) separately from the more risky one.
Note that:
deferPassiveEffectCleanupDuringUnmount
is ignored unlessrunAllPassiveEffectDestroysBeforeCreates
is also enabled.I've updated a couple of tests that were impacted by the change to explicitly test with both feature flag values so we don't have blind spots.
Be sure to use the
?w=1
param to see the significant lines changed (+393 −99
rather than+5,471 −5,177
).