Skip to content

Commit

Permalink
Remove feature flag enableStrictEffects
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy-SC committed Oct 3, 2022
1 parent 5581183 commit 9f6cf38
Show file tree
Hide file tree
Showing 24 changed files with 21 additions and 78 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 @@ -25,7 +25,6 @@ import {supportsResources, isHostResourceType} from './ReactFiberHostConfig';
import {
createRootStrictEffectsByDefault,
enableCache,
enableStrictEffects,
enableProfilerTimer,
enableScopeAPI,
enableLegacyHidden,
Expand Down Expand Up @@ -442,13 +441,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 @@ -511,7 +504,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 @@ -25,7 +25,6 @@ import {supportsResources, isHostResourceType} from './ReactFiberHostConfig';
import {
createRootStrictEffectsByDefault,
enableCache,
enableStrictEffects,
enableProfilerTimer,
enableScopeAPI,
enableLegacyHidden,
Expand Down Expand Up @@ -442,13 +441,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 @@ -511,7 +504,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
5 changes: 0 additions & 5 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 @@ -910,7 +909,6 @@ function mountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
Expand Down Expand Up @@ -988,7 +986,6 @@ function resumeMountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
Expand Down Expand Up @@ -1039,7 +1036,6 @@ function resumeMountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
Expand All @@ -1053,7 +1049,6 @@ function resumeMountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
Expand Down
5 changes: 0 additions & 5 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 @@ -910,7 +909,6 @@ function mountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
Expand Down Expand Up @@ -988,7 +986,6 @@ function resumeMountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
Expand Down Expand Up @@ -1039,7 +1036,6 @@ function resumeMountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
Expand All @@ -1053,7 +1049,6 @@ function resumeMountClassInstance(
let fiberFlags: Flags = Update | LayoutStatic;
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDev;
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 @@ -50,7 +50,6 @@ import {
enableCache,
enableTransitionTracing,
enableUseEventHook,
enableStrictEffects,
enableFloat,
} from 'shared/ReactFeatureFlags';
import {
Expand Down Expand Up @@ -4183,7 +4182,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 @@ -4211,7 +4210,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 @@ -4230,7 +4229,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 @@ -4260,7 +4259,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 @@ -50,7 +50,6 @@ import {
enableCache,
enableTransitionTracing,
enableUseEventHook,
enableStrictEffects,
enableFloat,
} from 'shared/ReactFeatureFlags';
import {
Expand Down Expand Up @@ -4183,7 +4182,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 @@ -4211,7 +4210,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 @@ -4230,7 +4229,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 @@ -4260,7 +4259,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
5 changes: 0 additions & 5 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
enableUseHook,
enableUseMemoCacheHook,
enableUseEventHook,
enableStrictEffects,
} from 'shared/ReactFeatureFlags';
import {
REACT_CONTEXT_TYPE,
Expand Down Expand Up @@ -602,7 +601,6 @@ export function bailoutHooks(
// complete phase (bubbleProperties).
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
workInProgress.flags &= ~(
Expand Down Expand Up @@ -1884,7 +1882,6 @@ function mountEffect(
): void {
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
return mountEffectImpl(
Expand Down Expand Up @@ -1979,7 +1976,6 @@ function mountLayoutEffect(
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDevEffect;
Expand Down Expand Up @@ -2046,7 +2042,6 @@ function mountImperativeHandle<T>(
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDevEffect;
Expand Down
5 changes: 0 additions & 5 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
enableUseHook,
enableUseMemoCacheHook,
enableUseEventHook,
enableStrictEffects,
} from 'shared/ReactFeatureFlags';
import {
REACT_CONTEXT_TYPE,
Expand Down Expand Up @@ -602,7 +601,6 @@ export function bailoutHooks(
// complete phase (bubbleProperties).
if (
__DEV__ &&
enableStrictEffects &&
(workInProgress.mode & StrictEffectsMode) !== NoMode
) {
workInProgress.flags &= ~(
Expand Down Expand Up @@ -1884,7 +1882,6 @@ function mountEffect(
): void {
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
return mountEffectImpl(
Expand Down Expand Up @@ -1979,7 +1976,6 @@ function mountLayoutEffect(
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
if (
__DEV__ &&
enableStrictEffects &&
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
) {
fiberFlags |= MountLayoutDevEffect;
Expand Down Expand Up @@ -2046,7 +2042,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 @@ -2580,7 +2579,7 @@ function commitRootImpl(
legacyErrorBoundariesThatAlreadyFailed = null;
}

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

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

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

Expand Down
7 changes: 3 additions & 4 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.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 @@ -2580,7 +2579,7 @@ function commitRootImpl(
legacyErrorBoundariesThatAlreadyFailed = null;
}

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

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

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

Expand Down
Loading

0 comments on commit 9f6cf38

Please sign in to comment.