Skip to content

Commit f2a59df

Browse files
authored
Remove unstableAvoidThisFallback from OSS (#22884)
* avoidThisFallbackFlag * avoidThisFallback flag * missed a spot * rm gating
1 parent d3001fb commit f2a59df

11 files changed

+34
-14
lines changed

‎packages/react-reconciler/src/ReactFiberBeginWork.new.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type {
2929
SpawnedCachePool,
3030
} from './ReactFiberCacheComponent.new';
3131
import type {UpdateQueue} from './ReactUpdateQueue.new';
32+
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
3233

3334
import checkPropTypes from 'shared/checkPropTypes';
3435
import {
@@ -1997,7 +1998,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
19971998
// Mark this subtree context as having at least one invisible parent that could
19981999
// handle the fallback state.
19992000
// 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+
) {
20012005
suspenseContext = addSubtreeSuspenseContext(
20022006
suspenseContext,
20032007
InvisibleParentSuspenseContext,

‎packages/react-reconciler/src/ReactFiberBeginWork.old.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type {
2929
SpawnedCachePool,
3030
} from './ReactFiberCacheComponent.old';
3131
import type {UpdateQueue} from './ReactUpdateQueue.old';
32+
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
3233

3334
import checkPropTypes from 'shared/checkPropTypes';
3435
import {
@@ -1997,7 +1998,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
19971998
// Mark this subtree context as having at least one invisible parent that could
19981999
// handle the fallback state.
19992000
// 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+
) {
20012005
suspenseContext = addSubtreeSuspenseContext(
20022006
suspenseContext,
20032007
InvisibleParentSuspenseContext,

‎packages/react-reconciler/src/ReactFiberCompleteWork.new.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type {
2929
import type {SuspenseContext} from './ReactFiberSuspenseContext.new';
3030
import type {OffscreenState} from './ReactFiberOffscreenComponent';
3131
import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent.new';
32+
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
3233

3334
import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.new';
3435

@@ -1154,7 +1155,8 @@ function completeWork(
11541155
// should be able to immediately restart from within throwException.
11551156
const hasInvisibleChildContext =
11561157
current === null &&
1157-
workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
1158+
(workInProgress.memoizedProps.unstable_avoidThisFallback !== true ||
1159+
!enableSuspenseAvoidThisFallback);
11581160
if (
11591161
hasInvisibleChildContext ||
11601162
hasSuspenseContext(

‎packages/react-reconciler/src/ReactFiberCompleteWork.old.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type {
2929
import type {SuspenseContext} from './ReactFiberSuspenseContext.old';
3030
import type {OffscreenState} from './ReactFiberOffscreenComponent';
3131
import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent.old';
32+
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
3233

3334
import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.old';
3435

@@ -1154,7 +1155,8 @@ function completeWork(
11541155
// should be able to immediately restart from within throwException.
11551156
const hasInvisibleChildContext =
11561157
current === null &&
1157-
workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
1158+
(workInProgress.memoizedProps.unstable_avoidThisFallback !== true ||
1159+
!enableSuspenseAvoidThisFallback);
11581160
if (
11591161
hasInvisibleChildContext ||
11601162
hasSuspenseContext(

‎packages/react-reconciler/src/ReactFiberSuspenseComponent.new.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {SuspenseInstance} from './ReactFiberHostConfig';
1313
import type {Lane} from './ReactFiberLane.new';
1414
import type {TreeContext} from './ReactFiberTreeContext.new';
1515

16+
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
1617
import {SuspenseComponent, SuspenseListComponent} from './ReactWorkTags';
1718
import {NoFlags, DidCapture} from './ReactFiberFlags';
1819
import {
@@ -81,7 +82,10 @@ export function shouldCaptureSuspense(
8182
}
8283
const props = workInProgress.memoizedProps;
8384
// Regular boundaries always capture.
84-
if (props.unstable_avoidThisFallback !== true) {
85+
if (
86+
!enableSuspenseAvoidThisFallback ||
87+
props.unstable_avoidThisFallback !== true
88+
) {
8589
return true;
8690
}
8791
// If it's a boundary we should avoid, then we prefer to bubble up to the

‎packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {SuspenseInstance} from './ReactFiberHostConfig';
1313
import type {Lane} from './ReactFiberLane.old';
1414
import type {TreeContext} from './ReactFiberTreeContext.old';
1515

16+
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
1617
import {SuspenseComponent, SuspenseListComponent} from './ReactWorkTags';
1718
import {NoFlags, DidCapture} from './ReactFiberFlags';
1819
import {
@@ -81,7 +82,10 @@ export function shouldCaptureSuspense(
8182
}
8283
const props = workInProgress.memoizedProps;
8384
// Regular boundaries always capture.
84-
if (props.unstable_avoidThisFallback !== true) {
85+
if (
86+
!enableSuspenseAvoidThisFallback ||
87+
props.unstable_avoidThisFallback !== true
88+
) {
8589
return true;
8690
}
8791
// If it's a boundary we should avoid, then we prefer to bubble up to the

‎packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ describe('ReactSuspenseList', () => {
688688
);
689689
});
690690

691-
// @gate enableSuspenseList
691+
// @gate enableSuspenseList && enableSuspenseAvoidThisFallback
692692
it('avoided boundaries can be coordinate with SuspenseList', async () => {
693693
const A = createAsyncText('A');
694694
const B = createAsyncText('B');

‎packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
22342234
expect(ReactNoop).toMatchRenderedOutput('Loading...');
22352235
});
22362236

2237-
// @gate enableCache
2237+
// @gate enableCache && enableSuspenseAvoidThisFallback
22382238
it('shows the parent fallback if the inner fallback should be avoided', async () => {
22392239
function Foo({showC}) {
22402240
Scheduler.unstable_yieldValue('Foo');
@@ -2372,7 +2372,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
23722372
expect(ReactNoop.getChildren()).toEqual([span('A'), span('Loading B...')]);
23732373
});
23742374

2375-
// @gate enableCache
2375+
// @gate enableCache && enableSuspenseAvoidThisFallback
23762376
it('keeps showing an avoided parent fallback if it is already showing', async () => {
23772377
function Foo({showB}) {
23782378
Scheduler.unstable_yieldValue('Foo');
@@ -2865,7 +2865,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
28652865
});
28662866
});
28672867

2868-
// @gate enableCache
2868+
// @gate enableCache && enableSuspenseAvoidThisFallback
28692869
it('do not show placeholder when updating an avoided boundary with startTransition', async () => {
28702870
function App({page}) {
28712871
return (
@@ -2909,7 +2909,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
29092909
);
29102910
});
29112911

2912-
// @gate enableCache
2912+
// @gate enableCache && enableSuspenseAvoidThisFallback
29132913
it('do not show placeholder when mounting an avoided boundary with startTransition', async () => {
29142914
function App({page}) {
29152915
return (

‎packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const disableModulePatternComponents = true;
4040
export const warnUnstableRenderSubtreeIntoContainer = false;
4141
export const warnAboutSpreadingKeyToJSX = false;
4242
export const warnOnSubscriptionInsideStartTransition = false;
43-
export const enableSuspenseAvoidThisFallback = false;
43+
export const enableSuspenseAvoidThisFallback = true;
4444
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
4545
export const enableClientRenderFallbackOnHydrationMismatch = true;
4646
export const enableComponentStackLocations = true;

‎packages/shared/forks/ReactFeatureFlags.testing.www.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const disableModulePatternComponents = true;
4040
export const warnUnstableRenderSubtreeIntoContainer = false;
4141
export const warnAboutSpreadingKeyToJSX = false;
4242
export const warnOnSubscriptionInsideStartTransition = false;
43-
export const enableSuspenseAvoidThisFallback = false;
43+
export const enableSuspenseAvoidThisFallback = true;
4444
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
4545
export const enableClientRenderFallbackOnHydrationMismatch = true;
4646
export const enableComponentStackLocations = true;

‎packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const enableProfilerNestedUpdateScheduledHook =
5050
export const enableUpdaterTracking = __PROFILE__;
5151

5252
export const enableSuspenseLayoutEffectSemantics = true;
53-
export const enableSuspenseAvoidThisFallback = false;
53+
export const enableSuspenseAvoidThisFallback = true;
5454

5555
// Logs additional User Timing API marks for use with an experimental profiling tool.
5656
export const enableSchedulingProfiler =

0 commit comments

Comments
 (0)