-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Separate strict effects mode feature flags #20847
Closed
Closed
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
facebook-github-bot
added
CLA Signed
React Core Team
Opened by a member of the React Core Team
labels
Feb 19, 2021
bvaughn
changed the title
Split strict effects mode feature flags
Separate strict effects mode feature flags
Feb 19, 2021
Comparing: 4190a34...a1d6475 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
|
bvaughn
force-pushed
the
strict-mode-separate-flags
branch
2 times, most recently
from
February 19, 2021 16:37
44d2f23
to
d79faf2
Compare
3 tasks
3 tasks
bvaughn
force-pushed
the
strict-mode-separate-flags
branch
from
February 22, 2021 20:13
d79faf2
to
2431a51
Compare
rickhanlonii
approved these changes
Feb 24, 2021
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 like this strategy a lot.
…y subtrees into strict mode level one ('mode == StrictModeL1'). This mode enables DEV-only double rendering, double component lifecycles, string ref warnings, legacy context warnings, etc. The primary purpose of this mode is to help detected render phase side effects. No new behavior. Roots created with experimental 'createRoot' and 'createBlockingRoot' APIs will also (for now) continue to default to strict mode level 1. In a subsequent commit I will add support for a 'level' attribute on the '<React.StrictMode>' tag (as well as a new option supported by ). This will be the way to opt into strict mode level 2 ('mode == StrictModeL2'). This mode will enable DEV-only double invoking of effects on initial mount. This will simulate future Offscreen API semantics for trees being mounted, then hidden, and then shown again. The primary purpose of this mode is to enable applications to prepare for compatibility with the new Offscreen API (more information to follow shortly). For now, this commit changes no public facing behavior. The only mechanism for opting into strict mode level 2 is the pre-existing 'enableDoubleInvokingEffects' feature flag (only enabled within Facebook for now).
StrictModeL1 -> StrictLegacyMode and StrictModeL2 -> StrictEffectsMode
One flag ('enableStrictEffects') enables strict mode level 2. It is similar to 'debugRenderPhaseSideEffectsForStrictMode' which enables srtict mode level 1. The second flag ('createRootStrictEffectsByDefault') controls the default strict mode level for 'createRoot' trees. For now, all 'createRoot' trees remain level 1 by default. We will experiment with level 2 within Facebook. This is a prerequisite for adding a configurable option to 'createRoot' that enables choosing a different StrictMode level than the default.
bvaughn
force-pushed
the
strict-mode-separate-flags
branch
from
February 24, 2021 20:24
2431a51
to
a1d6475
Compare
Merged via #20849 |
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.
PR Stack
Builds on top of PR #20844
The feature flag that was previously
debugRenderPhaseSideEffectsForStrictMode
has been split into two flags:enableStrictEffects
*: This enables the new strict effects mode.createRootStrictEffectsByDefault
: This determines whethercreateRoot
(andcreateBlockingRoot
) apps will default to strict effects mode (if true) or strict mode (if false).For now, both flags are only enabled within Facebook for testing purposes.
I've renamed strict effects test files slightly to better reflect their purpose but there were no other substantial changes.
Next step in this stack of PRs will be to add support for a new
StrictMode
"level" attribute to toggle between these modes as well as a newcreateRoot
option to change the default mode for the tree. This PR unblocks the latter.External changes?
For now, this commit changes no public facing behavior. The only mechanism for opting into strict mode level 2 is the
createRootStrictEffectsByDefault
feature flag (only enabled within Facebook for now).