@@ -278,7 +278,10 @@ import {
278278 createCapturedValueFromError ,
279279 createCapturedValueAtFiber ,
280280} from './ReactCapturedValue' ;
281- import { createInitialOffscreenInstance } from './ReactFiberOffscreenComponent' ;
281+ import {
282+ OffscreenHidden ,
283+ OffscreenVisible ,
284+ } from './ReactFiberOffscreenComponent' ;
282285import {
283286 createClassErrorUpdate ,
284287 initializeClassErrorUpdate ,
@@ -619,17 +622,21 @@ function updateOffscreenComponent(
619622 const prevState : OffscreenState | null =
620623 current !== null ? current . memoizedState : null ;
621624
625+ const nextHidden =
626+ nextProps . mode === 'hidden' ||
627+ ( enableLegacyHidden && nextProps . mode === 'unstable-defer-without-hiding' ) ;
628+
622629 if ( current === null && workInProgress . stateNode === null ) {
623- // We previously reset the work-in-progress.
624- // We need to create a new Offscreen instance.
625- const primaryChildInstance = createInitialOffscreenInstance ( ) ;
630+ const primaryChildInstance = {
631+ _visibility : nextHidden ? OffscreenHidden : OffscreenVisible ,
632+ _pendingMarkers : null ,
633+ _retryCache : null ,
634+ _transitions : null ,
635+ } ;
626636 workInProgress . stateNode = primaryChildInstance ;
627637 }
628638
629- if (
630- nextProps . mode === 'hidden' ||
631- ( enableLegacyHidden && nextProps . mode === 'unstable-defer-without-hiding' )
632- ) {
639+ if ( nextHidden ) {
633640 // Rendering a hidden tree.
634641
635642 const didSuspend = ( workInProgress . flags & DidCapture ) !== NoFlags ;
@@ -2806,7 +2813,7 @@ function mountSuspenseFallbackAfterRetryWithoutHydrating(
28062813) {
28072814 const fiberMode = workInProgress . mode ;
28082815 const primaryChildProps : OffscreenProps = {
2809- mode : 'visible ' ,
2816+ mode : 'hidden ' ,
28102817 children : primaryChildren ,
28112818 } ;
28122819 const primaryChildFragment = mountWorkInProgressOffscreenFiber (
@@ -2835,7 +2842,7 @@ function mountSuspenseFallbackAfterRetryWithoutHydrating(
28352842 reconcileChildFibers ( workInProgress , current . child , null , renderLanes ) ;
28362843 }
28372844
2838- return fallbackChildFragment ;
2845+ return primaryChildFragment ;
28392846}
28402847
28412848function mountDehydratedSuspenseComponent (
0 commit comments