@samitouri / QOS-React / commits / 3fbd6b7b50

Set hidden Offscreen to the shellBoundary regardless of previous state (#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.

Sebastian Markbåge committed Apr 22, 2025 at 19:39 UTC 3fbd6b7b50e3a174883633695586b892249e5635
1 file changed +4 -14
packages/react-reconciler/src/ReactFiberSuspenseContext.js
+4 -14
@@ -11,7 +11,6 @@ import type {SuspenseProps} from 'shared/ReactTypes';
11 import type {Fiber} from './ReactInternalTypes';
12 import type {StackCursor} from './ReactFiberStack';
13 import type {SuspenseState} from './ReactFiberSuspenseComponent';
14 -import type {OffscreenState} from './ReactFiberOffscreenComponent';
14
15 import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
16 import {createCursor, push, pop} from './ReactFiberStack';
@@ -115,19 +114,10 @@ export function pushOffscreenSuspenseHandler(fiber: Fiber): void {
114 // into separate functions for Suspense and Offscreen.
115 pushSuspenseListContext(fiber, suspenseStackCursor.current);
116 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;
121 }
122 } else {
123 // This is a LegacyHidden component.