Skip to content

Commit 3fbd6b7

Browse files
authored
Set hidden Offscreen to the shellBoundary regardless of previous state (facebook#32844)
I think this was probably just copy-paste from the Suspense path. It shouldn't matter what the previous state of an Offscreen boundary was. What matters is that it's now hidden and therefore if it suspends, we can just leave it as is without the tree becoming inconsistent.
1 parent ebf7318 commit 3fbd6b7

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

packages/react-reconciler/src/ReactFiberSuspenseContext.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {SuspenseProps} from 'shared/ReactTypes';
1111
import type {Fiber} from './ReactInternalTypes';
1212
import type {StackCursor} from './ReactFiberStack';
1313
import type {SuspenseState} from './ReactFiberSuspenseComponent';
14-
import type {OffscreenState} from './ReactFiberOffscreenComponent';
1514

1615
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
1716
import {createCursor, push, pop} from './ReactFiberStack';
@@ -115,19 +114,10 @@ export function pushOffscreenSuspenseHandler(fiber: Fiber): void {
115114
// into separate functions for Suspense and Offscreen.
116115
pushSuspenseListContext(fiber, suspenseStackCursor.current);
117116
push(suspenseHandlerStackCursor, fiber, fiber);
118-
if (shellBoundary !== null) {
119-
// A parent boundary is showing a fallback, so we've already rendered
120-
// deeper than the shell.
121-
} else {
122-
const current = fiber.alternate;
123-
if (current !== null) {
124-
const prevState: OffscreenState = current.memoizedState;
125-
if (prevState !== null) {
126-
// This is the first boundary in the stack that's already showing
127-
// a fallback. So everything outside is considered the shell.
128-
shellBoundary = fiber;
129-
}
130-
}
117+
if (shellBoundary === null) {
118+
// We're rendering hidden content. If it suspends, we can handle it by
119+
// just not committing the offscreen boundary.
120+
shellBoundary = fiber;
131121
}
132122
} else {
133123
// This is a LegacyHidden component.

0 commit comments

Comments
 (0)