Skip to content

Commit 26d16a0

Browse files
committed
Gate missing static flag check
1 parent d20c3af commit 26d16a0

11 files changed

+55
-38
lines changed

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
enableSuspenseLayoutEffectSemantics,
3434
enableUseMutableSource,
3535
enableTransitionTracing,
36+
enableStaticFlagMissingCheck,
3637
} from 'shared/ReactFeatureFlags';
3738

3839
import {
@@ -495,25 +496,27 @@ export function renderWithHooks<Props, SecondArg>(
495496
hookTypesDev = null;
496497
hookTypesUpdateIndexDev = -1;
497498

498-
// Confirm that a static flag was not added or removed since the last
499-
// render. If this fires, it suggests that we incorrectly reset the static
500-
// flags in some other part of the codebase. This has happened before, for
501-
// example, in the SuspenseList implementation.
502-
if (
503-
current !== null &&
504-
(current.flags & StaticMaskEffect) !==
505-
(workInProgress.flags & StaticMaskEffect) &&
506-
// Disable this warning in legacy mode, because legacy Suspense is weird
507-
// and creates false positives. To make this work in legacy mode, we'd
508-
// need to mark fibers that commit in an incomplete state, somehow. For
509-
// now I'll disable the warning that most of the bugs that would trigger
510-
// it are either exclusive to concurrent mode or exist in both.
511-
(current.mode & ConcurrentMode) !== NoMode
512-
) {
513-
console.error(
514-
'Internal React error: Expected static flag was missing. Please ' +
515-
'notify the React team.',
516-
);
499+
if (enableStaticFlagMissingCheck) {
500+
// Confirm that a static flag was not added or removed since the last
501+
// render. If this fires, it suggests that we incorrectly reset the static
502+
// flags in some other part of the codebase. This has happened before, for
503+
// example, in the SuspenseList implementation.
504+
if (
505+
current !== null &&
506+
(current.flags & StaticMaskEffect) !==
507+
(workInProgress.flags & StaticMaskEffect) &&
508+
// Disable this warning in legacy mode, because legacy Suspense is weird
509+
// and creates false positives. To make this work in legacy mode, we'd
510+
// need to mark fibers that commit in an incomplete state, somehow. For
511+
// now I'll disable the warning that most of the bugs that would trigger
512+
// it are either exclusive to concurrent mode or exist in both.
513+
(current.mode & ConcurrentMode) !== NoMode
514+
) {
515+
console.error(
516+
'Internal React error: Expected static flag was missing. Please ' +
517+
'notify the React team.',
518+
);
519+
}
517520
}
518521
}
519522

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
enableSuspenseLayoutEffectSemantics,
3434
enableUseMutableSource,
3535
enableTransitionTracing,
36+
enableStaticFlagMissingCheck,
3637
} from 'shared/ReactFeatureFlags';
3738

3839
import {
@@ -495,25 +496,27 @@ export function renderWithHooks<Props, SecondArg>(
495496
hookTypesDev = null;
496497
hookTypesUpdateIndexDev = -1;
497498

498-
// Confirm that a static flag was not added or removed since the last
499-
// render. If this fires, it suggests that we incorrectly reset the static
500-
// flags in some other part of the codebase. This has happened before, for
501-
// example, in the SuspenseList implementation.
502-
if (
503-
current !== null &&
504-
(current.flags & StaticMaskEffect) !==
505-
(workInProgress.flags & StaticMaskEffect) &&
506-
// Disable this warning in legacy mode, because legacy Suspense is weird
507-
// and creates false positives. To make this work in legacy mode, we'd
508-
// need to mark fibers that commit in an incomplete state, somehow. For
509-
// now I'll disable the warning that most of the bugs that would trigger
510-
// it are either exclusive to concurrent mode or exist in both.
511-
(current.mode & ConcurrentMode) !== NoMode
512-
) {
513-
console.error(
514-
'Internal React error: Expected static flag was missing. Please ' +
515-
'notify the React team.',
516-
);
499+
if (enableStaticFlagMissingCheck) {
500+
// Confirm that a static flag was not added or removed since the last
501+
// render. If this fires, it suggests that we incorrectly reset the static
502+
// flags in some other part of the codebase. This has happened before, for
503+
// example, in the SuspenseList implementation.
504+
if (
505+
current !== null &&
506+
(current.flags & StaticMaskEffect) !==
507+
(workInProgress.flags & StaticMaskEffect) &&
508+
// Disable this warning in legacy mode, because legacy Suspense is weird
509+
// and creates false positives. To make this work in legacy mode, we'd
510+
// need to mark fibers that commit in an incomplete state, somehow. For
511+
// now I'll disable the warning that most of the bugs that would trigger
512+
// it are either exclusive to concurrent mode or exist in both.
513+
(current.mode & ConcurrentMode) !== NoMode
514+
) {
515+
console.error(
516+
'Internal React error: Expected static flag was missing. Please ' +
517+
'notify the React team.',
518+
);
519+
}
517520
}
518521
}
519522

packages/shared/ReactFeatureFlags.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ export const enableSuspenseAvoidThisFallbackFizz = false;
112112

113113
export const enableCPUSuspense = __EXPERIMENTAL__;
114114

115+
// Tracking the error internally to catch mistakes.
116+
export const enableStaticFlagMissingCheck = false;
117+
115118
// When a node is unmounted, recurse into the Fiber subtree and clean out
116119
// references. Each level cleans up more fiber fields than the previous level.
117120
// As far as we know, React itself doesn't leak, but because the Fiber contains

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const warnAboutSpreadingKeyToJSX = false;
5050
export const enableSuspenseAvoidThisFallback = false;
5151
export const enableSuspenseAvoidThisFallbackFizz = false;
5252
export const enableCPUSuspense = true;
53+
export const enableStaticFlagMissingCheck = false;
5354
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
5455
export const enableClientRenderFallbackOnTextMismatch = true;
5556
export const enableComponentStackLocations = false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const warnAboutSpreadingKeyToJSX = false;
4040
export const enableSuspenseAvoidThisFallback = false;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
43+
export const enableStaticFlagMissingCheck = false;
4344
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
4445
export const enableClientRenderFallbackOnTextMismatch = true;
4546
export const enableComponentStackLocations = false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const warnAboutSpreadingKeyToJSX = false;
4040
export const enableSuspenseAvoidThisFallback = false;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
43+
export const enableStaticFlagMissingCheck = false;
4344
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
4445
export const enableClientRenderFallbackOnTextMismatch = true;
4546
export const enableComponentStackLocations = true;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const deferRenderPhaseUpdateToNextBatch = false;
5151
export const enableSuspenseAvoidThisFallback = false;
5252
export const enableSuspenseAvoidThisFallbackFizz = false;
5353
export const enableCPUSuspense = false;
54+
export const enableStaticFlagMissingCheck = false;
5455
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
5556
export const enableClientRenderFallbackOnTextMismatch = true;
5657
export const enableStrictEffects = false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const warnAboutSpreadingKeyToJSX = false;
4040
export const enableSuspenseAvoidThisFallback = true;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
43+
export const enableStaticFlagMissingCheck = false;
4344
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
4445
export const enableClientRenderFallbackOnTextMismatch = true;
4546
export const enableComponentStackLocations = true;

packages/shared/forks/ReactFeatureFlags.testing.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const warnAboutSpreadingKeyToJSX = false;
4040
export const enableSuspenseAvoidThisFallback = false;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
43+
export const enableStaticFlagMissingCheck = false;
4344
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
4445
export const enableClientRenderFallbackOnTextMismatch = true;
4546
export const enableComponentStackLocations = true;

packages/shared/forks/ReactFeatureFlags.testing.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const warnAboutSpreadingKeyToJSX = false;
4040
export const enableSuspenseAvoidThisFallback = true;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = true;
43+
export const enableStaticFlagMissingCheck = true;
4344
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
4445
export const enableClientRenderFallbackOnTextMismatch = true;
4546
export const enableComponentStackLocations = true;

0 commit comments

Comments
 (0)