From 659af98cdc035c159318e022365f01e14cebf66d Mon Sep 17 00:00:00 2001 From: Tianyu Yao Date: Tue, 20 Jun 2023 17:02:58 -0700 Subject: [PATCH] Add a feature flag to avoid leaking --- packages/react-reconciler/src/ReactFiber.js | 6 +++++- .../react/src/__tests__/ReactStrictMode-test.internal.js | 1 + packages/shared/ReactFeatureFlags.js | 1 + packages/shared/forks/ReactFeatureFlags.native-fb.js | 1 + packages/shared/forks/ReactFeatureFlags.native-oss.js | 1 + packages/shared/forks/ReactFeatureFlags.test-renderer.js | 1 + .../shared/forks/ReactFeatureFlags.test-renderer.native.js | 1 + .../shared/forks/ReactFeatureFlags.test-renderer.www.js | 1 + packages/shared/forks/ReactFeatureFlags.www-dynamic.js | 1 + packages/shared/forks/ReactFeatureFlags.www.js | 1 + 10 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js index ff98c8bba6bf1..15705b59787bf 100644 --- a/packages/react-reconciler/src/ReactFiber.js +++ b/packages/react-reconciler/src/ReactFiber.js @@ -39,6 +39,7 @@ import { enableDebugTracing, enableFloat, enableHostSingletons, + enableDO_NOT_USE_disableStrictPassiveEffect, } from 'shared/ReactFeatureFlags'; import {NoFlags, Placement, StaticMask} from './ReactFiberFlags'; import {ConcurrentRoot} from './ReactRootTags'; @@ -540,7 +541,10 @@ export function createFiberFromTypeAndProps( if ((mode & ConcurrentMode) !== NoMode) { // Strict effects should never run on legacy roots mode |= StrictEffectsMode; - if (pendingProps.DO_NOT_USE_disableStrictPassiveEffect) { + if ( + enableDO_NOT_USE_disableStrictPassiveEffect && + pendingProps.DO_NOT_USE_disableStrictPassiveEffect + ) { mode |= NoStrictPassiveEffectsMode; } } diff --git a/packages/react/src/__tests__/ReactStrictMode-test.internal.js b/packages/react/src/__tests__/ReactStrictMode-test.internal.js index 379196d9c50a7..11ed37f599715 100644 --- a/packages/react/src/__tests__/ReactStrictMode-test.internal.js +++ b/packages/react/src/__tests__/ReactStrictMode-test.internal.js @@ -104,6 +104,7 @@ describe('ReactStrictMode', () => { ]); }); + // @gate enableDO_NOT_USE_disableStrictPassiveEffect it('should include legacy + strict effects mode, but not strict passive effect with disableStrictPassiveEffect', async () => { await act(() => { const container = document.createElement('div'); diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 7cb339c83cc85..1236429619ae8 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -237,3 +237,4 @@ export const consoleManagedByDevToolsDuringStrictMode = true; // components will encounter in production, especially when used With . // TODO: clean up legacy once tests pass WWW. export const useModernStrictMode = false; +export const enableDO_NOT_USE_disableStrictPassiveEffect = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index e96ce86b00286..0edbf1eea7072 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -82,6 +82,7 @@ export const enableFloat = true; export const enableHostSingletons = true; export const useModernStrictMode = false; +export const enableDO_NOT_USE_disableStrictPassiveEffect = false; export const enableFizzExternalRuntime = false; export const diffInCommitPhase = true; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 97556a05514ce..1ad75cefa4954 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -68,6 +68,7 @@ export const enableFloat = true; export const enableHostSingletons = true; export const useModernStrictMode = false; +export const enableDO_NOT_USE_disableStrictPassiveEffect = false; export const enableFizzExternalRuntime = false; export const enableDeferRootSchedulingToMicrotask = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 6437b4de07086..67d35fbdd1e85 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -68,6 +68,7 @@ export const enableFloat = true; export const enableHostSingletons = true; export const useModernStrictMode = false; +export const enableDO_NOT_USE_disableStrictPassiveEffect = false; export const enableFizzExternalRuntime = false; export const enableDeferRootSchedulingToMicrotask = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js index 55535ce5e464d..0954b32e9af0b 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -66,6 +66,7 @@ export const enableFloat = true; export const enableHostSingletons = true; export const useModernStrictMode = false; +export const enableDO_NOT_USE_disableStrictPassiveEffect = false; export const enableDeferRootSchedulingToMicrotask = true; export const diffInCommitPhase = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 1df2ff6b9eeea..00808854a4d2e 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -70,6 +70,7 @@ export const enableFloat = true; export const enableHostSingletons = true; export const useModernStrictMode = false; +export const enableDO_NOT_USE_disableStrictPassiveEffect = false; export const enableFizzExternalRuntime = false; export const enableDeferRootSchedulingToMicrotask = true; diff --git a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js index 58cfcdfff4214..a1197be405837 100644 --- a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js @@ -28,6 +28,7 @@ export const enableDeferRootSchedulingToMicrotask = __VARIANT__; export const diffInCommitPhase = __VARIANT__; export const enableAsyncActions = __VARIANT__; export const alwaysThrottleRetries = __VARIANT__; +export const enableDO_NOT_USE_disableStrictPassiveEffect = __VARIANT__; // Enable this flag to help with concurrent mode debugging. // It logs information to the console about React scheduling, rendering, and commit phases. diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 426a9ec8013e6..36b5236df8319 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -30,6 +30,7 @@ export const { diffInCommitPhase, enableAsyncActions, alwaysThrottleRetries, + enableDO_NOT_USE_disableStrictPassiveEffect, } = dynamicFeatureFlags; // On WWW, __EXPERIMENTAL__ is used for a new modern build.