Remove unstableAvoidThisFallback from OSS (#22884)
* avoidThisFallbackFlag * avoidThisFallback flag * missed a spot * rm gating
salazarm committed
Dec 8, 2021 at 11:21 UTC
f2a59df48bec2352a4dd3b5415282a4ea240a4f8
11 files changed
+34
-14
packages/react-reconciler/src/ReactFiberBeginWork.new.js
+5
-1
@@ -29,6 +29,7 @@ import type {
29
SpawnedCachePool,
30
} from './ReactFiberCacheComponent.new';
31
import type {UpdateQueue} from './ReactUpdateQueue.new';
32
+import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
33
34
import checkPropTypes from 'shared/checkPropTypes';
35
import {
@@ -1997,7 +1998,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
1998
// Mark this subtree context as having at least one invisible parent that could
1999
// handle the fallback state.
2000
// Avoided boundaries are not considered since they cannot handle preferred fallback states.
2000
- if (nextProps.unstable_avoidThisFallback !== true) {
2001
+ if (
2002
+ !enableSuspenseAvoidThisFallback ||
2003
+ nextProps.unstable_avoidThisFallback !== true
2004
+ ) {
2005
suspenseContext = addSubtreeSuspenseContext(
2006
suspenseContext,
2007
InvisibleParentSuspenseContext,
packages/react-reconciler/src/ReactFiberBeginWork.old.js
+5
-1
@@ -29,6 +29,7 @@ import type {
29
SpawnedCachePool,
30
} from './ReactFiberCacheComponent.old';
31
import type {UpdateQueue} from './ReactUpdateQueue.old';
32
+import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
33
34
import checkPropTypes from 'shared/checkPropTypes';
35
import {
@@ -1997,7 +1998,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
1998
// Mark this subtree context as having at least one invisible parent that could
1999
// handle the fallback state.
2000
// Avoided boundaries are not considered since they cannot handle preferred fallback states.
2000
- if (nextProps.unstable_avoidThisFallback !== true) {
2001
+ if (
2002
+ !enableSuspenseAvoidThisFallback ||
2003
+ nextProps.unstable_avoidThisFallback !== true
2004
+ ) {
2005
suspenseContext = addSubtreeSuspenseContext(
2006
suspenseContext,
2007
InvisibleParentSuspenseContext,
packages/react-reconciler/src/ReactFiberCompleteWork.new.js
+3
-1
@@ -29,6 +29,7 @@ import type {
29
import type {SuspenseContext} from './ReactFiberSuspenseContext.new';
30
import type {OffscreenState} from './ReactFiberOffscreenComponent';
31
import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent.new';
32
+import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
33
34
import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.new';
35
@@ -1154,7 +1155,8 @@ function completeWork(
1155
// should be able to immediately restart from within throwException.
1156
const hasInvisibleChildContext =
1157
current === null &&
1157
- workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
1158
+ (workInProgress.memoizedProps.unstable_avoidThisFallback !== true ||
1159
+ !enableSuspenseAvoidThisFallback);
1160
if (
1161
hasInvisibleChildContext ||
1162
hasSuspenseContext(
packages/react-reconciler/src/ReactFiberCompleteWork.old.js
+3
-1
@@ -29,6 +29,7 @@ import type {
29
import type {SuspenseContext} from './ReactFiberSuspenseContext.old';
30
import type {OffscreenState} from './ReactFiberOffscreenComponent';
31
import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent.old';
32
+import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
33
34
import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.old';
35
@@ -1154,7 +1155,8 @@ function completeWork(
1155
// should be able to immediately restart from within throwException.
1156
const hasInvisibleChildContext =
1157
current === null &&
1157
- workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
1158
+ (workInProgress.memoizedProps.unstable_avoidThisFallback !== true ||
1159
+ !enableSuspenseAvoidThisFallback);
1160
if (
1161
hasInvisibleChildContext ||
1162
hasSuspenseContext(
packages/react-reconciler/src/ReactFiberSuspenseComponent.new.js
+5
-1
@@ -13,6 +13,7 @@ import type {SuspenseInstance} from './ReactFiberHostConfig';
13
import type {Lane} from './ReactFiberLane.new';
14
import type {TreeContext} from './ReactFiberTreeContext.new';
15
16
+import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
17
import {SuspenseComponent, SuspenseListComponent} from './ReactWorkTags';
18
import {NoFlags, DidCapture} from './ReactFiberFlags';
19
import {
@@ -81,7 +82,10 @@ export function shouldCaptureSuspense(
82
}
83
const props = workInProgress.memoizedProps;
84
// Regular boundaries always capture.
84
- if (props.unstable_avoidThisFallback !== true) {
85
+ if (
86
+ !enableSuspenseAvoidThisFallback ||
87
+ props.unstable_avoidThisFallback !== true
88
+ ) {
89
return true;
90
}
91
// If it's a boundary we should avoid, then we prefer to bubble up to the
packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js
+5
-1
@@ -13,6 +13,7 @@ import type {SuspenseInstance} from './ReactFiberHostConfig';
13
import type {Lane} from './ReactFiberLane.old';
14
import type {TreeContext} from './ReactFiberTreeContext.old';
15
16
+import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
17
import {SuspenseComponent, SuspenseListComponent} from './ReactWorkTags';
18
import {NoFlags, DidCapture} from './ReactFiberFlags';
19
import {
@@ -81,7 +82,10 @@ export function shouldCaptureSuspense(
82
}
83
const props = workInProgress.memoizedProps;
84
// Regular boundaries always capture.
84
- if (props.unstable_avoidThisFallback !== true) {
85
+ if (
86
+ !enableSuspenseAvoidThisFallback ||
87
+ props.unstable_avoidThisFallback !== true
88
+ ) {
89
return true;
90
}
91
// If it's a boundary we should avoid, then we prefer to bubble up to the
packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js
+1
-1
@@ -688,7 +688,7 @@ describe('ReactSuspenseList', () => {
688
);
689
});
690
691
- // @gate enableSuspenseList
691
+ // @gate enableSuspenseList && enableSuspenseAvoidThisFallback
692
it('avoided boundaries can be coordinate with SuspenseList', async () => {
693
const A = createAsyncText('A');
694
const B = createAsyncText('B');
packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js
+4
-4
@@ -2234,7 +2234,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2234
expect(ReactNoop).toMatchRenderedOutput('Loading...');
2235
});
2236
2237
- // @gate enableCache
2237
+ // @gate enableCache && enableSuspenseAvoidThisFallback
2238
it('shows the parent fallback if the inner fallback should be avoided', async () => {
2239
function Foo({showC}) {
2240
Scheduler.unstable_yieldValue('Foo');
@@ -2372,7 +2372,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2372
expect(ReactNoop.getChildren()).toEqual([span('A'), span('Loading B...')]);
2373
});
2374
2375
- // @gate enableCache
2375
+ // @gate enableCache && enableSuspenseAvoidThisFallback
2376
it('keeps showing an avoided parent fallback if it is already showing', async () => {
2377
function Foo({showB}) {
2378
Scheduler.unstable_yieldValue('Foo');
@@ -2865,7 +2865,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2865
});
2866
});
2867
2868
- // @gate enableCache
2868
+ // @gate enableCache && enableSuspenseAvoidThisFallback
2869
it('do not show placeholder when updating an avoided boundary with startTransition', async () => {
2870
function App({page}) {
2871
return (
@@ -2909,7 +2909,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2909
);
2910
});
2911
2912
- // @gate enableCache
2912
+ // @gate enableCache && enableSuspenseAvoidThisFallback
2913
it('do not show placeholder when mounting an avoided boundary with startTransition', async () => {
2914
function App({page}) {
2915
return (
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1
-1
@@ -40,7 +40,7 @@ export const disableModulePatternComponents = true;
40
export const warnUnstableRenderSubtreeIntoContainer = false;
41
export const warnAboutSpreadingKeyToJSX = false;
42
export const warnOnSubscriptionInsideStartTransition = false;
43
-export const enableSuspenseAvoidThisFallback = false;
43
+export const enableSuspenseAvoidThisFallback = true;
44
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
45
export const enableClientRenderFallbackOnHydrationMismatch = true;
46
export const enableComponentStackLocations = true;
packages/shared/forks/ReactFeatureFlags.testing.www.js
+1
-1
@@ -40,7 +40,7 @@ export const disableModulePatternComponents = true;
40
export const warnUnstableRenderSubtreeIntoContainer = false;
41
export const warnAboutSpreadingKeyToJSX = false;
42
export const warnOnSubscriptionInsideStartTransition = false;
43
-export const enableSuspenseAvoidThisFallback = false;
43
+export const enableSuspenseAvoidThisFallback = true;
44
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
45
export const enableClientRenderFallbackOnHydrationMismatch = true;
46
export const enableComponentStackLocations = true;
packages/shared/forks/ReactFeatureFlags.www.js
+1
-1
@@ -50,7 +50,7 @@ export const enableProfilerNestedUpdateScheduledHook =
50
export const enableUpdaterTracking = __PROFILE__;
51
52
export const enableSuspenseLayoutEffectSemantics = true;
53
-export const enableSuspenseAvoidThisFallback = false;
53
+export const enableSuspenseAvoidThisFallback = true;
54
55
// Logs additional User Timing API marks for use with an experimental profiling tool.
56
export const enableSchedulingProfiler =