mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Move modern strict to experimental (#28152)
Turn this on Edited: ope, nvm <details> Looks like there's still an outstanding issue with this. The original PR turned off a strict effects test, which causes a stray `componentWillUnmount` to fire. https://github.com/facebook/react/commit/5d1ce651393524639a3b4b1e861a0413a4d25629#diff-19df471970763c4790c2cc0811fd2726cc6a891b0e1d5dedbf6d0599240c127aR70 Before: ```js expect(log).toEqual([ 'constructor', 'constructor', 'getDerivedStateFromProps', 'getDerivedStateFromProps', 'render', 'render', 'componentDidMount', ]); ``` After: ```js expect(log).toEqual([ 'constructor', 'constructor', 'getDerivedStateFromProps', 'getDerivedStateFromProps', 'render', 'render', 'componentDidMount', 'componentWillUnmount', 'componentDidMount', ]); ``` So there's a bug somewhere </details>
This commit is contained in:
+1
-4
@@ -3792,12 +3792,9 @@ function commitDoubleInvokeEffectsInDEV(
|
||||
hasPassiveEffects: boolean,
|
||||
) {
|
||||
if (__DEV__) {
|
||||
if (useModernStrictMode) {
|
||||
if (useModernStrictMode && root.tag !== LegacyRoot) {
|
||||
let doubleInvokeEffects = true;
|
||||
|
||||
if (root.tag === LegacyRoot && !(root.current.mode & StrictLegacyMode)) {
|
||||
doubleInvokeEffects = false;
|
||||
}
|
||||
if (
|
||||
root.tag === ConcurrentRoot &&
|
||||
!(root.current.mode & (StrictLegacyMode | StrictEffectsMode))
|
||||
|
||||
@@ -147,7 +147,7 @@ export const disableJavaScriptURLs = false;
|
||||
// Modern <StrictMode /> behaviour aligns more with what components
|
||||
// components will encounter in production, especially when used With <Offscreen />.
|
||||
// TODO: clean up legacy <StrictMode /> once tests pass WWW.
|
||||
export const useModernStrictMode = false;
|
||||
export const useModernStrictMode = __NEXT_MAJOR__;
|
||||
|
||||
// Not ready to break experimental yet.
|
||||
// Remove IE and MsApp specific workarounds for innerHTML
|
||||
|
||||
Reference in New Issue
Block a user