Skip to content

Commit

Permalink
Remove feature flag enableStrictEffects (#25387)
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy-SC authored Oct 19, 2022
1 parent 8e2bde6 commit 9872928
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 118 deletions.
11 changes: 2 additions & 9 deletions packages/react-reconciler/src/ReactFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
import {
createRootStrictEffectsByDefault,
enableCache,
enableStrictEffects,
enableProfilerTimer,
enableScopeAPI,
enableLegacyHidden,
Expand Down Expand Up @@ -449,13 +448,7 @@ export function createHostRootFiber(
let mode;
if (tag === ConcurrentRoot) {
mode = ConcurrentMode;
if (isStrictMode === true) {
mode |= StrictLegacyMode;

if (enableStrictEffects) {
mode |= StrictEffectsMode;
}
} else if (enableStrictEffects && createRootStrictEffectsByDefault) {
if (isStrictMode === true || createRootStrictEffectsByDefault) {
mode |= StrictLegacyMode | StrictEffectsMode;
}
if (
Expand Down Expand Up @@ -531,7 +524,7 @@ export function createFiberFromTypeAndProps(
case REACT_STRICT_MODE_TYPE:
fiberTag = Mode;
mode |= StrictLegacyMode;
if (enableStrictEffects && (mode & ConcurrentMode) !== NoMode) {
if ((mode & ConcurrentMode) !== NoMode) {
// Strict effects should never run on legacy roots
mode |= StrictEffectsMode;
}
Expand Down
11 changes: 2 additions & 9 deletions packages/react-reconciler/src/ReactFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
import {
createRootStrictEffectsByDefault,
enableCache,
enableStrictEffects,
enableProfilerTimer,
enableScopeAPI,
enableLegacyHidden,
Expand Down Expand Up @@ -449,13 +448,7 @@ export function createHostRootFiber(
let mode;
if (tag === ConcurrentRoot) {
mode = ConcurrentMode;
if (isStrictMode === true) {
mode |= StrictLegacyMode;

if (enableStrictEffects) {
mode |= StrictEffectsMode;
}
} else if (enableStrictEffects && createRootStrictEffectsByDefault) {
if (isStrictMode === true || createRootStrictEffectsByDefault) {
mode |= StrictLegacyMode | StrictEffectsMode;
}
if (
Expand Down Expand Up @@ -531,7 +524,7 @@ export function createFiberFromTypeAndProps(
case REACT_STRICT_MODE_TYPE:
fiberTag = Mode;
mode |= StrictLegacyMode;
if (enableStrictEffects && (mode & ConcurrentMode) !== NoMode) {
if ((mode & ConcurrentMode) !== NoMode) {
// Strict effects should never run on legacy roots
mode |= StrictEffectsMode;
}
Expand Down
25 changes: 4 additions & 21 deletions packages/react-reconciler/src/ReactFiberClassComponent.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
enableSchedulingProfiler,
warnAboutDeprecatedLifecycles,
enableLazyContextPropagation,
enableStrictEffects,
} from 'shared/ReactFeatureFlags';
import ReactStrictModeWarnings from './ReactStrictModeWarnings.new';
import {isMounted} from './ReactFiberTreeReflection';
Expand Down Expand Up @@ -908,11 +907,7 @@ function mountClassInstance(

if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand Down Expand Up @@ -986,11 +981,7 @@ function resumeMountClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand Down Expand Up @@ -1037,11 +1028,7 @@ function resumeMountClassInstance(
}
if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand All @@ -1051,11 +1038,7 @@ function resumeMountClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand Down
25 changes: 4 additions & 21 deletions packages/react-reconciler/src/ReactFiberClassComponent.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
enableSchedulingProfiler,
warnAboutDeprecatedLifecycles,
enableLazyContextPropagation,
enableStrictEffects,
} from 'shared/ReactFeatureFlags';
import ReactStrictModeWarnings from './ReactStrictModeWarnings.old';
import {isMounted} from './ReactFiberTreeReflection';
Expand Down Expand Up @@ -908,11 +907,7 @@ function mountClassInstance(

if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand Down Expand Up @@ -986,11 +981,7 @@ function resumeMountClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand Down Expand Up @@ -1037,11 +1028,7 @@ function resumeMountClassInstance(
}
if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand All @@ -1051,11 +1038,7 @@ function resumeMountClassInstance(
// effect even though we're bailing out, so that cWU/cDU are called.
if (typeof instance.componentDidMount === 'function') {
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
fiberFlags |= MountLayoutDev;
}
workInProgress.flags |= fiberFlags;
Expand Down
9 changes: 4 additions & 5 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
enableCache,
enableTransitionTracing,
enableUseEventHook,
enableStrictEffects,
enableFloat,
enableLegacyHidden,
enableHostSingletons,
Expand Down Expand Up @@ -4350,7 +4349,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
}

function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
// We don't need to re-check StrictEffectsMode here.
// This function is only called if that check has already passed.
switch (fiber.tag) {
Expand Down Expand Up @@ -4378,7 +4377,7 @@ function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
}

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

function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
// We don't need to re-check StrictEffectsMode here.
// This function is only called if that check has already passed.
switch (fiber.tag) {
Expand Down Expand Up @@ -4427,7 +4426,7 @@ function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
}

function invokePassiveEffectUnmountInDEV(fiber: Fiber): void {
if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
// We don't need to re-check StrictEffectsMode here.
// This function is only called if that check has already passed.
switch (fiber.tag) {
Expand Down
9 changes: 4 additions & 5 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
enableCache,
enableTransitionTracing,
enableUseEventHook,
enableStrictEffects,
enableFloat,
enableLegacyHidden,
enableHostSingletons,
Expand Down Expand Up @@ -4350,7 +4349,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
}

function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
// We don't need to re-check StrictEffectsMode here.
// This function is only called if that check has already passed.
switch (fiber.tag) {
Expand Down Expand Up @@ -4378,7 +4377,7 @@ function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
}

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

function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
// We don't need to re-check StrictEffectsMode here.
// This function is only called if that check has already passed.
switch (fiber.tag) {
Expand Down Expand Up @@ -4427,7 +4426,7 @@ function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
}

function invokePassiveEffectUnmountInDEV(fiber: Fiber): void {
if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
// We don't need to re-check StrictEffectsMode here.
// This function is only called if that check has already passed.
switch (fiber.tag) {
Expand Down
10 changes: 1 addition & 9 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
enableUseHook,
enableUseMemoCacheHook,
enableUseEventHook,
enableStrictEffects,
} from 'shared/ReactFeatureFlags';
import {
REACT_CONTEXT_TYPE,
Expand Down Expand Up @@ -602,11 +601,7 @@ export function bailoutHooks(
workInProgress.updateQueue = current.updateQueue;
// TODO: Don't need to reset the flags here, because they're reset in the
// complete phase (bubbleProperties).
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
workInProgress.flags &= ~(
MountPassiveDevEffect |
MountLayoutDevEffect |
Expand Down Expand Up @@ -1888,7 +1883,6 @@ function mountEffect(
): void {
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
return mountEffectImpl(
Expand Down Expand Up @@ -1984,7 +1978,6 @@ function mountLayoutEffect(
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDevEffect;
Expand Down Expand Up @@ -2051,7 +2044,6 @@ function mountImperativeHandle<T>(
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDevEffect;
Expand Down
10 changes: 1 addition & 9 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
enableUseHook,
enableUseMemoCacheHook,
enableUseEventHook,
enableStrictEffects,
} from 'shared/ReactFeatureFlags';
import {
REACT_CONTEXT_TYPE,
Expand Down Expand Up @@ -602,11 +601,7 @@ export function bailoutHooks(
workInProgress.updateQueue = current.updateQueue;
// TODO: Don't need to reset the flags here, because they're reset in the
// complete phase (bubbleProperties).
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
if (__DEV__ && (workInProgress.mode & StrictEffectsMode) !== NoMode) {
workInProgress.flags &= ~(
MountPassiveDevEffect |
MountLayoutDevEffect |
Expand Down Expand Up @@ -1888,7 +1883,6 @@ function mountEffect(
): void {
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
return mountEffectImpl(
Expand Down Expand Up @@ -1984,7 +1978,6 @@ function mountLayoutEffect(
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDevEffect;
Expand Down Expand Up @@ -2051,7 +2044,6 @@ function mountImperativeHandle<T>(
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDevEffect;
Expand Down
7 changes: 3 additions & 4 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
enableDebugTracing,
enableSchedulingProfiler,
disableSchedulerTimeoutInWorkLoop,
enableStrictEffects,
skipUnmountedBoundaries,
enableUpdaterTracking,
enableCache,
Expand Down Expand Up @@ -2610,7 +2609,7 @@ function commitRootImpl(
legacyErrorBoundariesThatAlreadyFailed = null;
}

if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
if (!rootDidHavePassiveEffects) {
commitDoubleInvokeEffectsInDEV(root, false);
}
Expand Down Expand Up @@ -2887,7 +2886,7 @@ function flushPassiveEffectsImpl() {
markPassiveEffectsStopped();
}

if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
commitDoubleInvokeEffectsInDEV(root, true);
}

Expand Down Expand Up @@ -3356,7 +3355,7 @@ function commitDoubleInvokeEffectsInDEV(
root: FiberRoot,
hasPassiveEffects: boolean,
) {
if (__DEV__ && enableStrictEffects) {
if (__DEV__) {
if (useModernStrictMode) {
let doubleInvokeEffects = true;

Expand Down
Loading

0 comments on commit 9872928

Please sign in to comment.