Skip to content

Commit f1d4697

Browse files
author
Brian Vaughn
committed
Split strict effects warning into two flags
This lets us (a) can enable it for 100% of Facebook engineers¹² and (b) provide a simple opt-out mechanism for engineers who know about the mode and no longer want to see the warning. ¹ This warning will not be logged for legacy applications that aren't in strict effects mode. ² GKs within Facebook can't be enabled for 100% of a population.
1 parent edf51d1 commit f1d4697

13 files changed

+46
-2
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
enableDoubleInvokingEffects,
3636
skipUnmountedBoundaries,
3737
enableStrictEffectsModeDevWarningForFacebookOnly,
38+
bypassStrictEffectsModeDevWarningForFacebookOnly,
3839
} from 'shared/ReactFeatureFlags';
3940
import ReactSharedInternals from 'shared/ReactSharedInternals';
4041
import invariant from 'shared/invariant';
@@ -2591,7 +2592,11 @@ function commitDoubleInvokeEffectsInDEV(
25912592
return;
25922593
}
25932594

2594-
if (__DEV__ && enableStrictEffectsModeDevWarningForFacebookOnly) {
2595+
if (
2596+
__DEV__ &&
2597+
enableStrictEffectsModeDevWarningForFacebookOnly &&
2598+
!bypassStrictEffectsModeDevWarningForFacebookOnly
2599+
) {
25952600
if (!didWarnAboutStrictEffectsMode) {
25962601
didWarnAboutStrictEffectsMode = true;
25972602

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
skipUnmountedBoundaries,
3737
enableDiscreteEventMicroTasks,
3838
enableStrictEffectsModeDevWarningForFacebookOnly,
39+
bypassStrictEffectsModeDevWarningForFacebookOnly,
3940
} from 'shared/ReactFeatureFlags';
4041
import ReactSharedInternals from 'shared/ReactSharedInternals';
4142
import invariant from 'shared/invariant';
@@ -2571,7 +2572,11 @@ function commitDoubleInvokeEffectsInDEV(
25712572
return;
25722573
}
25732574

2574-
if (__DEV__ && enableStrictEffectsModeDevWarningForFacebookOnly) {
2575+
if (
2576+
__DEV__ &&
2577+
enableStrictEffectsModeDevWarningForFacebookOnly &&
2578+
!bypassStrictEffectsModeDevWarningForFacebookOnly
2579+
) {
25752580
if (!didWarnAboutStrictEffectsMode) {
25762581
didWarnAboutStrictEffectsMode = true;
25772582

packages/react-reconciler/src/__tests__/ReactDoubleInvokeEvents-test.internal.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ describe('ReactDoubleInvokeEvents', () => {
8282
);
8383
});
8484
});
85+
86+
it('should not log if bypass flag has been enabled (by GK allowlist)', () => {
87+
ReactFeatureFlags.bypassStrictEffectsModeDevWarningForFacebookOnly = true;
88+
89+
function Component() {
90+
React.useLayoutEffect(() => {}, []);
91+
return null;
92+
}
93+
94+
ReactNoop.act(() => {
95+
ReactNoop.render(
96+
<React.StrictMode>
97+
<Component />
98+
</React.StrictMode>,
99+
);
100+
});
101+
});
85102
});
86103

87104
it('should not double invoke effects in legacy mode', () => {

packages/shared/ReactFeatureFlags.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,12 @@ export const enableDiscreteEventMicroTasks = false;
160160
// Facebook specific instructions for how to disable it (using a GK blocklist).
161161
// If we decide to add a similar warning for OSS we'll need to revisit both the
162162
// wording and the opt-out mechansim.
163+
//
164+
// This warning is controlled by two flags so that (a) we can enable it for 100%
165+
// of Facebook engineers¹² only and (b) provide a simple opt-out mechanism for engineers
166+
// who know about the mode and no longer want to see the warning.
167+
//
168+
// ¹ This warning will not be logged for legacy applications that aren't in strict effects mode.
169+
// ² GKs within Facebook can't be enabled for 100% of a population.
163170
export const enableStrictEffectsModeDevWarningForFacebookOnly = false;
171+
export const bypassStrictEffectsModeDevWarningForFacebookOnly = false;

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
6161
export const enableTransitionEntanglement = false;
6262
export const enableDiscreteEventMicroTasks = false;
6363
export const enableStrictEffectsModeDevWarningForFacebookOnly = false;
64+
export const bypassStrictEffectsModeDevWarningForFacebookOnly = false;
6465

6566
// Flow magic to verify the exports of this file match the original version.
6667
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableTransitionEntanglement = false;
6161
export const enableDiscreteEventMicroTasks = false;
6262
export const enableStrictEffectsModeDevWarningForFacebookOnly = false;
63+
export const bypassStrictEffectsModeDevWarningForFacebookOnly = false;
6364

6465
// Flow magic to verify the exports of this file match the original version.
6566
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableTransitionEntanglement = false;
6161
export const enableDiscreteEventMicroTasks = false;
6262
export const enableStrictEffectsModeDevWarningForFacebookOnly = false;
63+
export const bypassStrictEffectsModeDevWarningForFacebookOnly = false;
6364

6465
// Flow magic to verify the exports of this file match the original version.
6566
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const enableFilterEmptyStringAttributesDOM = false;
4747
export const disableNativeComponentFrames = false;
4848
export const skipUnmountedBoundaries = false;
4949
export const enableStrictEffectsModeDevWarningForFacebookOnly = false;
50+
export const bypassStrictEffectsModeDevWarningForFacebookOnly = false;
5051

5152
export const enableNewReconciler = false;
5253
export const deferRenderPhaseUpdateToNextBatch = true;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableTransitionEntanglement = false;
6161
export const enableDiscreteEventMicroTasks = false;
6262
export const enableStrictEffectsModeDevWarningForFacebookOnly = false;
63+
export const bypassStrictEffectsModeDevWarningForFacebookOnly = false;
6364

6465
// Flow magic to verify the exports of this file match the original version.
6566
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.testing.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableTransitionEntanglement = false;
6161
export const enableDiscreteEventMicroTasks = false;
6262
export const enableStrictEffectsModeDevWarningForFacebookOnly = false;
63+
export const bypassStrictEffectsModeDevWarningForFacebookOnly = false;
6364

6465
// Flow magic to verify the exports of this file match the original version.
6566
// eslint-disable-next-line no-unused-vars

0 commit comments

Comments
 (0)