From 06e410ec608820b65d81536bb4630228b4e04d48 Mon Sep 17 00:00:00 2001 From: Ricky Date: Fri, 9 Feb 2024 16:59:47 -0500 Subject: [PATCH] Move modern strict to experimental (#28152) Turn this on Edited: ope, nvm
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
--- packages/react-reconciler/src/ReactFiberWorkLoop.js | 5 +---- packages/shared/ReactFeatureFlags.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index 5fafd8de5c903..d045fa08496e1 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -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)) diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 67862a4f14288..3d8a7cf563bc8 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -147,7 +147,7 @@ export const disableJavaScriptURLs = false; // Modern behaviour aligns more with what components // components will encounter in production, especially when used With . // TODO: clean up legacy 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