Skip to content

Commit 4ed84b0

Browse files
author
Brian Vaughn
committed
Removed the enableGetDerivedStateFromCatch feature flag (aka permanently enabled the feature)
1 parent a0733fe commit 4ed84b0

13 files changed

+5
-31
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import {
4646
import {captureWillSyncRenderPlaceholder} from './ReactFiberScheduler';
4747
import ReactSharedInternals from 'shared/ReactSharedInternals';
4848
import {
49-
enableGetDerivedStateFromCatch,
5049
enableSuspense,
5150
debugRenderPhaseSideEffects,
5251
debugRenderPhaseSideEffectsForStrictMode,
@@ -444,8 +443,7 @@ function finishClassComponent(
444443
let nextChildren;
445444
if (
446445
didCaptureError &&
447-
(!enableGetDerivedStateFromCatch ||
448-
typeof Component.getDerivedStateFromCatch !== 'function')
446+
typeof Component.getDerivedStateFromCatch !== 'function'
449447
) {
450448
// If we captured an error, but getDerivedStateFrom catch is not defined,
451449
// unmount all the children. componentDidCatch will schedule an update to

packages/react-reconciler/src/ReactFiberUnwindWork.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ import {
3333
Update as UpdateEffect,
3434
LifecycleEffectMask,
3535
} from 'shared/ReactSideEffectTags';
36-
import {
37-
enableGetDerivedStateFromCatch,
38-
enableSuspense,
39-
enableSchedulerTracing,
40-
} from 'shared/ReactFeatureFlags';
36+
import {enableSuspense, enableSchedulerTracing} from 'shared/ReactFeatureFlags';
4137
import {StrictMode, ConcurrentMode} from './ReactTypeOfMode';
4238

4339
import {createCapturedValue} from './ReactCapturedValue';
@@ -105,10 +101,7 @@ function createClassErrorUpdate(
105101
const update = createUpdate(expirationTime);
106102
update.tag = CaptureUpdate;
107103
const getDerivedStateFromCatch = fiber.type.getDerivedStateFromCatch;
108-
if (
109-
enableGetDerivedStateFromCatch &&
110-
typeof getDerivedStateFromCatch === 'function'
111-
) {
104+
if (typeof getDerivedStateFromCatch === 'function') {
112105
const error = errorInfo.value;
113106
update.payload = () => {
114107
return getDerivedStateFromCatch(error);
@@ -118,10 +111,7 @@ function createClassErrorUpdate(
118111
const inst = fiber.stateNode;
119112
if (inst !== null && typeof inst.componentDidCatch === 'function') {
120113
update.callback = function callback() {
121-
if (
122-
!enableGetDerivedStateFromCatch ||
123-
getDerivedStateFromCatch !== 'function'
124-
) {
114+
if (getDerivedStateFromCatch !== 'function') {
125115
// To preserve the preexisting retry behavior of error boundaries,
126116
// we keep track of which ones already failed during this batch.
127117
// This gets reset before we yield back to the browser.
@@ -364,8 +354,7 @@ function throwException(
364354
const instance = workInProgress.stateNode;
365355
if (
366356
(workInProgress.effectTag & DidCapture) === NoEffect &&
367-
((typeof ctor.getDerivedStateFromCatch === 'function' &&
368-
enableGetDerivedStateFromCatch) ||
357+
(typeof ctor.getDerivedStateFromCatch === 'function' ||
369358
(instance !== null &&
370359
typeof instance.componentDidCatch === 'function' &&
371360
!isAlreadyFailedLegacyErrorBoundary(instance)))

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('ReactIncrementalErrorHandling', () => {
1919
beforeEach(() => {
2020
jest.resetModules();
2121
ReactFeatureFlags = require('shared/ReactFeatureFlags');
22-
ReactFeatureFlags.enableGetDerivedStateFromCatch = true;
2322
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
2423
ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
2524
PropTypes = require('prop-types');

packages/react/src/__tests__/ReactProfiler-test.internal.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function loadModules({
3636
ReactFeatureFlags.debugRenderPhaseSideEffects = false;
3737
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
3838
ReactFeatureFlags.enableProfilerTimer = enableProfilerTimer;
39-
ReactFeatureFlags.enableGetDerivedStateFromCatch = true;
4039
ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing;
4140
ReactFeatureFlags.enableSuspense = enableSuspense;
4241
ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = replayFailedUnitOfWorkWithInvokeGuardedCallback;

packages/shared/ReactFeatureFlags.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
// Exports ReactDOM.createRoot
1111
export const enableUserTimingAPI = __DEV__;
1212

13-
// Experimental error-boundary API that can recover from errors within a single
14-
// render phase
15-
export const enableGetDerivedStateFromCatch = false;
1613
// Suspense
1714
export const enableSuspense = false;
1815
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabri
1515
export const debugRenderPhaseSideEffects = false;
1616
export const debugRenderPhaseSideEffectsForStrictMode = false;
1717
export const enableUserTimingAPI = __DEV__;
18-
export const enableGetDerivedStateFromCatch = false;
1918
export const enableSuspense = false;
2019
export const warnAboutDeprecatedLifecycles = false;
2120
export const warnAboutLegacyContextAPI = __DEV__;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabri
1515
export const debugRenderPhaseSideEffects = false;
1616
export const debugRenderPhaseSideEffectsForStrictMode = false;
1717
export const enableUserTimingAPI = __DEV__;
18-
export const enableGetDerivedStateFromCatch = false;
1918
export const enableSuspense = false;
2019
export const warnAboutDeprecatedLifecycles = false;
2120
export const warnAboutLegacyContextAPI = false;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-fb';
1414

1515
// Re-export dynamic flags from the fbsource version.
1616
export const {
17-
enableGetDerivedStateFromCatch,
1817
enableSuspense,
1918
debugRenderPhaseSideEffects,
2019
debugRenderPhaseSideEffectsForStrictMode,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-oss';
1414

1515
export const debugRenderPhaseSideEffects = false;
1616
export const debugRenderPhaseSideEffectsForStrictMode = false;
17-
export const enableGetDerivedStateFromCatch = false;
1817
export const enableSuspense = false;
1918
export const enableUserTimingAPI = __DEV__;
2019
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;

packages/shared/forks/ReactFeatureFlags.persistent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persiste
1515
export const debugRenderPhaseSideEffects = false;
1616
export const debugRenderPhaseSideEffectsForStrictMode = false;
1717
export const enableUserTimingAPI = __DEV__;
18-
export const enableGetDerivedStateFromCatch = false;
1918
export const enableSuspense = false;
2019
export const warnAboutDeprecatedLifecycles = false;
2120
export const warnAboutLegacyContextAPI = false;

0 commit comments

Comments
 (0)