Skip to content
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

Add concept of StrictMode levels 1 & 2 (no public API yet) #20844

Closed
wants to merge 2 commits into from

Commits on Feb 24, 2021

  1. The exported '<React.StrictMode>' tag remains the same and opts legac…

    …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).
    Brian Vaughn committed Feb 24, 2021
    Configuration menu
    Copy the full SHA
    42f6a5e View commit details
    Browse the repository at this point in the history
  2. Renamed strict mode constants

    StrictModeL1 -> StrictLegacyMode and StrictModeL2 -> StrictEffectsMode
    Brian Vaughn committed Feb 24, 2021
    Configuration menu
    Copy the full SHA
    372bb8b View commit details
    Browse the repository at this point in the history