Skip to content

Commit faf6c4d

Browse files
authored
[flags] Remove debugRenderPhaseSideEffectsForStrictMode (facebook#31839)
This is enabled everywhere, we can just use the inline `__DEV__` checks.
1 parent ef979d4 commit faf6c4d

15 files changed

+13
-61
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ import {
9292
DidDefer,
9393
} from './ReactFiberFlags';
9494
import {
95-
debugRenderPhaseSideEffectsForStrictMode,
9695
disableLegacyContext,
9796
disableLegacyContextForFunctionComponents,
9897
enableProfilerCommitHooks,
@@ -1375,10 +1374,7 @@ function finishClassComponent(
13751374
}
13761375
if (__DEV__) {
13771376
nextChildren = callRenderInDEV(instance);
1378-
if (
1379-
debugRenderPhaseSideEffectsForStrictMode &&
1380-
workInProgress.mode & StrictLegacyMode
1381-
) {
1377+
if (workInProgress.mode & StrictLegacyMode) {
13821378
setIsStrictModeForDevtools(true);
13831379
try {
13841380
callRenderInDEV(instance);

packages/react-reconciler/src/ReactFiberClassComponent.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
MountLayoutDev,
1919
} from './ReactFiberFlags';
2020
import {
21-
debugRenderPhaseSideEffectsForStrictMode,
2221
disableLegacyContext,
2322
enableSchedulingProfiler,
2423
disableDefaultPropsExceptForClasses,
@@ -138,10 +137,7 @@ function applyDerivedStateFromProps(
138137
const prevState = workInProgress.memoizedState;
139138
let partialState = getDerivedStateFromProps(nextProps, prevState);
140139
if (__DEV__) {
141-
if (
142-
debugRenderPhaseSideEffectsForStrictMode &&
143-
workInProgress.mode & StrictLegacyMode
144-
) {
140+
if (workInProgress.mode & StrictLegacyMode) {
145141
setIsStrictModeForDevtools(true);
146142
try {
147143
// Invoke the function an extra time to help detect side-effects.
@@ -266,10 +262,7 @@ function checkShouldComponentUpdate(
266262
nextContext,
267263
);
268264
if (__DEV__) {
269-
if (
270-
debugRenderPhaseSideEffectsForStrictMode &&
271-
workInProgress.mode & StrictLegacyMode
272-
) {
265+
if (workInProgress.mode & StrictLegacyMode) {
273266
setIsStrictModeForDevtools(true);
274267
try {
275268
// Invoke the function an extra time to help detect side-effects.
@@ -598,10 +591,7 @@ function constructClassInstance(
598591
let instance = new ctor(props, context);
599592
// Instantiate twice to help detect side-effects.
600593
if (__DEV__) {
601-
if (
602-
debugRenderPhaseSideEffectsForStrictMode &&
603-
workInProgress.mode & StrictLegacyMode
604-
) {
594+
if (workInProgress.mode & StrictLegacyMode) {
605595
setIsStrictModeForDevtools(true);
606596
try {
607597
instance = new ctor(props, context);

packages/react-reconciler/src/ReactFiberClassUpdateQueue.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ import {
110110
} from './ReactFiberFlags';
111111
import getComponentNameFromFiber from './getComponentNameFromFiber';
112112

113-
import {debugRenderPhaseSideEffectsForStrictMode} from 'shared/ReactFeatureFlags';
114-
115113
import {StrictLegacyMode} from './ReactTypeOfMode';
116114
import {
117115
markSkippedUpdateLanes,
@@ -402,10 +400,7 @@ function getStateFromUpdate<State>(
402400
}
403401
const nextState = payload.call(instance, prevState, nextProps);
404402
if (__DEV__) {
405-
if (
406-
debugRenderPhaseSideEffectsForStrictMode &&
407-
workInProgress.mode & StrictLegacyMode
408-
) {
403+
if (workInProgress.mode & StrictLegacyMode) {
409404
setIsStrictModeForDevtools(true);
410405
try {
411406
payload.call(instance, prevState, nextProps);
@@ -435,10 +430,7 @@ function getStateFromUpdate<State>(
435430
}
436431
partialState = payload.call(instance, prevState, nextProps);
437432
if (__DEV__) {
438-
if (
439-
debugRenderPhaseSideEffectsForStrictMode &&
440-
workInProgress.mode & StrictLegacyMode
441-
) {
433+
if (workInProgress.mode & StrictLegacyMode) {
442434
setIsStrictModeForDevtools(true);
443435
try {
444436
payload.call(instance, prevState, nextProps);

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
enableUseEffectEventHook,
4141
enableUseResourceEffectHook,
4242
enableLegacyCache,
43-
debugRenderPhaseSideEffectsForStrictMode,
4443
disableLegacyMode,
4544
enableNoCloningMemoCache,
4645
} from 'shared/ReactFeatureFlags';
@@ -623,9 +622,7 @@ export function renderWithHooks<Props, SecondArg>(
623622
//
624623
// There are plenty of tests to ensure this behavior is correct.
625624
const shouldDoubleRenderDEV =
626-
__DEV__ &&
627-
debugRenderPhaseSideEffectsForStrictMode &&
628-
(workInProgress.mode & StrictLegacyMode) !== NoMode;
625+
__DEV__ && (workInProgress.mode & StrictLegacyMode) !== NoMode;
629626

630627
shouldDoubleInvokeUserFnsInHooksDEV = shouldDoubleRenderDEV;
631628
let children = __DEV__

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
'use strict';
1414

1515
let React;
16-
let ReactFeatureFlags;
1716
let ReactTestRenderer;
1817
let Scheduler;
1918
let ReactDOMServer;
@@ -26,8 +25,6 @@ let waitForThrow;
2625
describe('ReactHooks', () => {
2726
beforeEach(() => {
2827
jest.resetModules();
29-
ReactFeatureFlags = require('shared/ReactFeatureFlags');
30-
3128
React = require('react');
3229
ReactTestRenderer = require('react-test-renderer');
3330
Scheduler = require('scheduler');
@@ -1240,8 +1237,6 @@ describe('ReactHooks', () => {
12401237
});
12411238

12421239
it('double-invokes components with Hooks in Strict Mode', async () => {
1243-
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = true;
1244-
12451240
const {useState, StrictMode} = React;
12461241
let renderCount = 0;
12471242

@@ -1459,7 +1454,6 @@ describe('ReactHooks', () => {
14591454
});
14601455

14611456
it('double-invokes useMemo in DEV StrictMode despite []', async () => {
1462-
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = true;
14631457
const {useMemo, StrictMode} = React;
14641458

14651459
let useMemoCount = 0;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ describe('updaters', () => {
3434

3535
ReactFeatureFlags = require('shared/ReactFeatureFlags');
3636
ReactFeatureFlags.enableUpdaterTracking = true;
37-
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
3837

3938
mockDevToolsHook = {
4039
injectInternals: jest.fn(() => {}),

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ describe('useRef', () => {
2828
ReactNoop = require('react-noop-renderer');
2929
Scheduler = require('scheduler');
3030

31-
const ReactFeatureFlags = require('shared/ReactFeatureFlags');
32-
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
33-
3431
act = require('internal-test-utils').act;
3532
useCallback = React.useCallback;
3633
useEffect = React.useEffect;

packages/react/src/__tests__/ReactStrictMode-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe('ReactStrictMode', () => {
202202
expect(instance.state.count).toBe(2);
203203
});
204204

205-
// @gate debugRenderPhaseSideEffectsForStrictMode
205+
// @gate __DEV__
206206
it('double invokes useState and useReducer initializers functions', async () => {
207207
const log = [];
208208

@@ -390,7 +390,7 @@ describe('ReactStrictMode', () => {
390390
expect(instance.state.count).toBe(2);
391391
});
392392

393-
// @gate debugRenderPhaseSideEffectsForStrictMode
393+
// @gate __DEV__
394394
it('double invokes useMemo functions', async () => {
395395
let log = [];
396396

@@ -436,7 +436,7 @@ describe('ReactStrictMode', () => {
436436
]);
437437
});
438438

439-
// @gate debugRenderPhaseSideEffectsForStrictMode
439+
// @gate __DEV__
440440
it('double invokes useMemo functions with first result', async () => {
441441
let log = [];
442442
function Uppercased({text}) {
@@ -499,7 +499,7 @@ describe('ReactStrictMode', () => {
499499
expect(log[2]).toBe(log[3]);
500500
});
501501

502-
// @gate debugRenderPhaseSideEffectsForStrictMode
502+
// @gate __DEV__
503503
it('double invokes setState updater functions', async () => {
504504
const log = [];
505505

@@ -532,7 +532,7 @@ describe('ReactStrictMode', () => {
532532
expect(log).toEqual(['Compute count: 1', 'Compute count: 1']);
533533
});
534534

535-
// @gate debugRenderPhaseSideEffectsForStrictMode
535+
// @gate __DEV__
536536
it('double invokes reducer functions', async () => {
537537
const log = [];
538538

packages/shared/ReactFeatureFlags.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,6 @@ export const disableTextareaChildren = false;
234234
// Debugging and DevTools
235235
// -----------------------------------------------------------------------------
236236

237-
// Helps identify side effects in render-phase lifecycle hooks and setState
238-
// reducers by double invoking them in StrictLegacyMode.
239-
export const debugRenderPhaseSideEffectsForStrictMode = __DEV__;
240-
241237
// Gather advanced timing metrics for Profiler subtrees.
242238
export const enableProfilerTimer = __PROFILE__;
243239

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const {
3232
} = dynamicFlags;
3333

3434
// The rest of the flags are static for better dead code elimination.
35-
export const debugRenderPhaseSideEffectsForStrictMode = __DEV__;
3635
export const disableClientCache = true;
3736
export const disableCommentsAsDOMContainers = true;
3837
export const disableDefaultPropsExceptForClasses = true;

0 commit comments

Comments
 (0)