Skip to content

Commit 9872928

Browse files
authored
Remove feature flag enableStrictEffects (#25387)
1 parent 8e2bde6 commit 9872928

24 files changed

+31
-118
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
import {
3131
createRootStrictEffectsByDefault,
3232
enableCache,
33-
enableStrictEffects,
3433
enableProfilerTimer,
3534
enableScopeAPI,
3635
enableLegacyHidden,
@@ -449,13 +448,7 @@ export function createHostRootFiber(
449448
let mode;
450449
if (tag === ConcurrentRoot) {
451450
mode = ConcurrentMode;
452-
if (isStrictMode === true) {
453-
mode |= StrictLegacyMode;
454-
455-
if (enableStrictEffects) {
456-
mode |= StrictEffectsMode;
457-
}
458-
} else if (enableStrictEffects && createRootStrictEffectsByDefault) {
451+
if (isStrictMode === true || createRootStrictEffectsByDefault) {
459452
mode |= StrictLegacyMode | StrictEffectsMode;
460453
}
461454
if (
@@ -531,7 +524,7 @@ export function createFiberFromTypeAndProps(
531524
case REACT_STRICT_MODE_TYPE:
532525
fiberTag = Mode;
533526
mode |= StrictLegacyMode;
534-
if (enableStrictEffects && (mode & ConcurrentMode) !== NoMode) {
527+
if ((mode & ConcurrentMode) !== NoMode) {
535528
// Strict effects should never run on legacy roots
536529
mode |= StrictEffectsMode;
537530
}

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
import {
3131
createRootStrictEffectsByDefault,
3232
enableCache,
33-
enableStrictEffects,
3433
enableProfilerTimer,
3534
enableScopeAPI,
3635
enableLegacyHidden,
@@ -449,13 +448,7 @@ export function createHostRootFiber(
449448
let mode;
450449
if (tag === ConcurrentRoot) {
451450
mode = ConcurrentMode;
452-
if (isStrictMode === true) {
453-
mode |= StrictLegacyMode;
454-
455-
if (enableStrictEffects) {
456-
mode |= StrictEffectsMode;
457-
}
458-
} else if (enableStrictEffects && createRootStrictEffectsByDefault) {
451+
if (isStrictMode === true || createRootStrictEffectsByDefault) {
459452
mode |= StrictLegacyMode | StrictEffectsMode;
460453
}
461454
if (
@@ -531,7 +524,7 @@ export function createFiberFromTypeAndProps(
531524
case REACT_STRICT_MODE_TYPE:
532525
fiberTag = Mode;
533526
mode |= StrictLegacyMode;
534-
if (enableStrictEffects && (mode & ConcurrentMode) !== NoMode) {
527+
if ((mode & ConcurrentMode) !== NoMode) {
535528
// Strict effects should never run on legacy roots
536529
mode |= StrictEffectsMode;
537530
}

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

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
enableSchedulingProfiler,
2727
warnAboutDeprecatedLifecycles,
2828
enableLazyContextPropagation,
29-
enableStrictEffects,
3029
} from 'shared/ReactFeatureFlags';
3130
import ReactStrictModeWarnings from './ReactStrictModeWarnings.new';
3231
import {isMounted} from './ReactFiberTreeReflection';
@@ -908,11 +907,7 @@ function mountClassInstance(
908907

909908
if (typeof instance.componentDidMount === 'function') {
910909
let fiberFlags: Flags = Update | LayoutStatic;
911-
if (
912-
__DEV__ &&
913-
enableStrictEffects &&
914-
(workInProgress.mode & StrictEffectsMode) !== NoMode
915-
) {
910+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
916911
fiberFlags |= MountLayoutDev;
917912
}
918913
workInProgress.flags |= fiberFlags;
@@ -986,11 +981,7 @@ function resumeMountClassInstance(
986981
// effect even though we're bailing out, so that cWU/cDU are called.
987982
if (typeof instance.componentDidMount === 'function') {
988983
let fiberFlags: Flags = Update | LayoutStatic;
989-
if (
990-
__DEV__ &&
991-
enableStrictEffects &&
992-
(workInProgress.mode & StrictEffectsMode) !== NoMode
993-
) {
984+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
994985
fiberFlags |= MountLayoutDev;
995986
}
996987
workInProgress.flags |= fiberFlags;
@@ -1037,11 +1028,7 @@ function resumeMountClassInstance(
10371028
}
10381029
if (typeof instance.componentDidMount === 'function') {
10391030
let fiberFlags: Flags = Update | LayoutStatic;
1040-
if (
1041-
__DEV__ &&
1042-
enableStrictEffects &&
1043-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1044-
) {
1031+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
10451032
fiberFlags |= MountLayoutDev;
10461033
}
10471034
workInProgress.flags |= fiberFlags;
@@ -1051,11 +1038,7 @@ function resumeMountClassInstance(
10511038
// effect even though we're bailing out, so that cWU/cDU are called.
10521039
if (typeof instance.componentDidMount === 'function') {
10531040
let fiberFlags: Flags = Update | LayoutStatic;
1054-
if (
1055-
__DEV__ &&
1056-
enableStrictEffects &&
1057-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1058-
) {
1041+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
10591042
fiberFlags |= MountLayoutDev;
10601043
}
10611044
workInProgress.flags |= fiberFlags;

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

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
enableSchedulingProfiler,
2727
warnAboutDeprecatedLifecycles,
2828
enableLazyContextPropagation,
29-
enableStrictEffects,
3029
} from 'shared/ReactFeatureFlags';
3130
import ReactStrictModeWarnings from './ReactStrictModeWarnings.old';
3231
import {isMounted} from './ReactFiberTreeReflection';
@@ -908,11 +907,7 @@ function mountClassInstance(
908907

909908
if (typeof instance.componentDidMount === 'function') {
910909
let fiberFlags: Flags = Update | LayoutStatic;
911-
if (
912-
__DEV__ &&
913-
enableStrictEffects &&
914-
(workInProgress.mode & StrictEffectsMode) !== NoMode
915-
) {
910+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
916911
fiberFlags |= MountLayoutDev;
917912
}
918913
workInProgress.flags |= fiberFlags;
@@ -986,11 +981,7 @@ function resumeMountClassInstance(
986981
// effect even though we're bailing out, so that cWU/cDU are called.
987982
if (typeof instance.componentDidMount === 'function') {
988983
let fiberFlags: Flags = Update | LayoutStatic;
989-
if (
990-
__DEV__ &&
991-
enableStrictEffects &&
992-
(workInProgress.mode & StrictEffectsMode) !== NoMode
993-
) {
984+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
994985
fiberFlags |= MountLayoutDev;
995986
}
996987
workInProgress.flags |= fiberFlags;
@@ -1037,11 +1028,7 @@ function resumeMountClassInstance(
10371028
}
10381029
if (typeof instance.componentDidMount === 'function') {
10391030
let fiberFlags: Flags = Update | LayoutStatic;
1040-
if (
1041-
__DEV__ &&
1042-
enableStrictEffects &&
1043-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1044-
) {
1031+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
10451032
fiberFlags |= MountLayoutDev;
10461033
}
10471034
workInProgress.flags |= fiberFlags;
@@ -1051,11 +1038,7 @@ function resumeMountClassInstance(
10511038
// effect even though we're bailing out, so that cWU/cDU are called.
10521039
if (typeof instance.componentDidMount === 'function') {
10531040
let fiberFlags: Flags = Update | LayoutStatic;
1054-
if (
1055-
__DEV__ &&
1056-
enableStrictEffects &&
1057-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1058-
) {
1041+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
10591042
fiberFlags |= MountLayoutDev;
10601043
}
10611044
workInProgress.flags |= fiberFlags;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import {
5454
enableCache,
5555
enableTransitionTracing,
5656
enableUseEventHook,
57-
enableStrictEffects,
5857
enableFloat,
5958
enableLegacyHidden,
6059
enableHostSingletons,
@@ -4350,7 +4349,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
43504349
}
43514350

43524351
function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
4353-
if (__DEV__ && enableStrictEffects) {
4352+
if (__DEV__) {
43544353
// We don't need to re-check StrictEffectsMode here.
43554354
// This function is only called if that check has already passed.
43564355
switch (fiber.tag) {
@@ -4378,7 +4377,7 @@ function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
43784377
}
43794378

43804379
function invokePassiveEffectMountInDEV(fiber: Fiber): void {
4381-
if (__DEV__ && enableStrictEffects) {
4380+
if (__DEV__) {
43824381
// We don't need to re-check StrictEffectsMode here.
43834382
// This function is only called if that check has already passed.
43844383
switch (fiber.tag) {
@@ -4397,7 +4396,7 @@ function invokePassiveEffectMountInDEV(fiber: Fiber): void {
43974396
}
43984397

43994398
function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
4400-
if (__DEV__ && enableStrictEffects) {
4399+
if (__DEV__) {
44014400
// We don't need to re-check StrictEffectsMode here.
44024401
// This function is only called if that check has already passed.
44034402
switch (fiber.tag) {
@@ -4427,7 +4426,7 @@ function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
44274426
}
44284427

44294428
function invokePassiveEffectUnmountInDEV(fiber: Fiber): void {
4430-
if (__DEV__ && enableStrictEffects) {
4429+
if (__DEV__) {
44314430
// We don't need to re-check StrictEffectsMode here.
44324431
// This function is only called if that check has already passed.
44334432
switch (fiber.tag) {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import {
5454
enableCache,
5555
enableTransitionTracing,
5656
enableUseEventHook,
57-
enableStrictEffects,
5857
enableFloat,
5958
enableLegacyHidden,
6059
enableHostSingletons,
@@ -4350,7 +4349,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
43504349
}
43514350

43524351
function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
4353-
if (__DEV__ && enableStrictEffects) {
4352+
if (__DEV__) {
43544353
// We don't need to re-check StrictEffectsMode here.
43554354
// This function is only called if that check has already passed.
43564355
switch (fiber.tag) {
@@ -4378,7 +4377,7 @@ function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
43784377
}
43794378

43804379
function invokePassiveEffectMountInDEV(fiber: Fiber): void {
4381-
if (__DEV__ && enableStrictEffects) {
4380+
if (__DEV__) {
43824381
// We don't need to re-check StrictEffectsMode here.
43834382
// This function is only called if that check has already passed.
43844383
switch (fiber.tag) {
@@ -4397,7 +4396,7 @@ function invokePassiveEffectMountInDEV(fiber: Fiber): void {
43974396
}
43984397

43994398
function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
4400-
if (__DEV__ && enableStrictEffects) {
4399+
if (__DEV__) {
44014400
// We don't need to re-check StrictEffectsMode here.
44024401
// This function is only called if that check has already passed.
44034402
switch (fiber.tag) {
@@ -4427,7 +4426,7 @@ function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
44274426
}
44284427

44294428
function invokePassiveEffectUnmountInDEV(fiber: Fiber): void {
4430-
if (__DEV__ && enableStrictEffects) {
4429+
if (__DEV__) {
44314430
// We don't need to re-check StrictEffectsMode here.
44324431
// This function is only called if that check has already passed.
44334432
switch (fiber.tag) {

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import {
4141
enableUseHook,
4242
enableUseMemoCacheHook,
4343
enableUseEventHook,
44-
enableStrictEffects,
4544
} from 'shared/ReactFeatureFlags';
4645
import {
4746
REACT_CONTEXT_TYPE,
@@ -602,11 +601,7 @@ export function bailoutHooks(
602601
workInProgress.updateQueue = current.updateQueue;
603602
// TODO: Don't need to reset the flags here, because they're reset in the
604603
// complete phase (bubbleProperties).
605-
if (
606-
__DEV__ &&
607-
enableStrictEffects &&
608-
(workInProgress.mode & StrictEffectsMode) !== NoMode
609-
) {
604+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
610605
workInProgress.flags &= ~(
611606
MountPassiveDevEffect |
612607
MountLayoutDevEffect |
@@ -1888,7 +1883,6 @@ function mountEffect(
18881883
): void {
18891884
if (
18901885
__DEV__ &&
1891-
enableStrictEffects &&
18921886
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
18931887
) {
18941888
return mountEffectImpl(
@@ -1984,7 +1978,6 @@ function mountLayoutEffect(
19841978
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
19851979
if (
19861980
__DEV__ &&
1987-
enableStrictEffects &&
19881981
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
19891982
) {
19901983
fiberFlags |= MountLayoutDevEffect;
@@ -2051,7 +2044,6 @@ function mountImperativeHandle<T>(
20512044
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
20522045
if (
20532046
__DEV__ &&
2054-
enableStrictEffects &&
20552047
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
20562048
) {
20572049
fiberFlags |= MountLayoutDevEffect;

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import {
4141
enableUseHook,
4242
enableUseMemoCacheHook,
4343
enableUseEventHook,
44-
enableStrictEffects,
4544
} from 'shared/ReactFeatureFlags';
4645
import {
4746
REACT_CONTEXT_TYPE,
@@ -602,11 +601,7 @@ export function bailoutHooks(
602601
workInProgress.updateQueue = current.updateQueue;
603602
// TODO: Don't need to reset the flags here, because they're reset in the
604603
// complete phase (bubbleProperties).
605-
if (
606-
__DEV__ &&
607-
enableStrictEffects &&
608-
(workInProgress.mode & StrictEffectsMode) !== NoMode
609-
) {
604+
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
610605
workInProgress.flags &= ~(
611606
MountPassiveDevEffect |
612607
MountLayoutDevEffect |
@@ -1888,7 +1883,6 @@ function mountEffect(
18881883
): void {
18891884
if (
18901885
__DEV__ &&
1891-
enableStrictEffects &&
18921886
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
18931887
) {
18941888
return mountEffectImpl(
@@ -1984,7 +1978,6 @@ function mountLayoutEffect(
19841978
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
19851979
if (
19861980
__DEV__ &&
1987-
enableStrictEffects &&
19881981
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
19891982
) {
19901983
fiberFlags |= MountLayoutDevEffect;
@@ -2051,7 +2044,6 @@ function mountImperativeHandle<T>(
20512044
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
20522045
if (
20532046
__DEV__ &&
2054-
enableStrictEffects &&
20552047
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
20562048
) {
20572049
fiberFlags |= MountLayoutDevEffect;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
enableDebugTracing,
3636
enableSchedulingProfiler,
3737
disableSchedulerTimeoutInWorkLoop,
38-
enableStrictEffects,
3938
skipUnmountedBoundaries,
4039
enableUpdaterTracking,
4140
enableCache,
@@ -2610,7 +2609,7 @@ function commitRootImpl(
26102609
legacyErrorBoundariesThatAlreadyFailed = null;
26112610
}
26122611

2613-
if (__DEV__ && enableStrictEffects) {
2612+
if (__DEV__) {
26142613
if (!rootDidHavePassiveEffects) {
26152614
commitDoubleInvokeEffectsInDEV(root, false);
26162615
}
@@ -2887,7 +2886,7 @@ function flushPassiveEffectsImpl() {
28872886
markPassiveEffectsStopped();
28882887
}
28892888

2890-
if (__DEV__ && enableStrictEffects) {
2889+
if (__DEV__) {
28912890
commitDoubleInvokeEffectsInDEV(root, true);
28922891
}
28932892

@@ -3356,7 +3355,7 @@ function commitDoubleInvokeEffectsInDEV(
33563355
root: FiberRoot,
33573356
hasPassiveEffects: boolean,
33583357
) {
3359-
if (__DEV__ && enableStrictEffects) {
3358+
if (__DEV__) {
33603359
if (useModernStrictMode) {
33613360
let doubleInvokeEffects = true;
33623361

0 commit comments

Comments
 (0)