@@ -13,6 +13,7 @@ import type {ExpirationTime} from './ReactFiberExpirationTime';
1313import type { CapturedValue } from './ReactCapturedValue' ;
1414import type { Update } from './ReactUpdateQueue' ;
1515import type { Thenable } from './ReactFiberScheduler' ;
16+ import type { SuspenseContext } from './ReactFiberSuspenseContext' ;
1617
1718import { unstable_wrap as Schedule_tracing_wrap } from 'scheduler/tracing' ;
1819import getComponentName from 'shared/getComponentName' ;
@@ -55,7 +56,12 @@ import {
5556import { logError } from './ReactFiberCommitWork' ;
5657import { getStackByFiberInDevAndProd } from './ReactCurrentFiber' ;
5758import { popHostContainer , popHostContext } from './ReactFiberHostContext' ;
58- import { popSuspenseContext } from './ReactFiberSuspenseContext' ;
59+ import {
60+ suspenseStackCursor ,
61+ InvisibleParentSuspenseContext ,
62+ hasSuspenseContext ,
63+ popSuspenseContext ,
64+ } from './ReactFiberSuspenseContext' ;
5965import {
6066 isContextProvider as isLegacyContextProvider ,
6167 popContext as popLegacyContext ,
@@ -207,15 +213,17 @@ function throwException(
207213
208214 checkForWrongSuspensePriorityInDEV ( sourceFiber ) ;
209215
210- // TODO: If we're not in an invisible subtree, then we need to mark this render
211- // as needing to suspend for longer to avoid showing this fallback state.
216+ let hasInvisibleParentBoundary = hasSuspenseContext (
217+ suspenseStackCursor . current ,
218+ ( InvisibleParentSuspenseContext : SuspenseContext ) ,
219+ ) ;
212220
213221 // Schedule the nearest Suspense to re-render the timed out view.
214222 let workInProgress = returnFiber ;
215223 do {
216224 if (
217225 workInProgress . tag === SuspenseComponent &&
218- shouldCaptureSuspense ( workInProgress )
226+ shouldCaptureSuspense ( workInProgress , hasInvisibleParentBoundary )
219227 ) {
220228 // Found the nearest boundary.
221229
@@ -278,6 +286,13 @@ function throwException(
278286
279287 workInProgress . effectTag |= ShouldCapture ;
280288 workInProgress . expirationTime = renderExpirationTime ;
289+
290+ if ( ! hasInvisibleParentBoundary ) {
291+ // TODO: If we're not in an invisible subtree, then we need to mark this render
292+ // pass as needing to suspend for longer to avoid showing this fallback state.
293+ // We could do it here or when we render the fallback.
294+ }
295+
281296 return ;
282297 } else if (
283298 enableSuspenseServerRenderer &&
0 commit comments