diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js index 86a0ceb42e84a..deef07d6ef663 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js @@ -3723,6 +3723,11 @@ describe('ReactDOMServerPartialHydration', () => { + + + + + ); } @@ -3743,6 +3748,10 @@ describe('ReactDOMServerPartialHydration', () => { + + + + `); @@ -3758,6 +3767,7 @@ describe('ReactDOMServerPartialHydration', () => { await waitForPaint([]); } // Subsequently, the hidden child is prerendered on the client + // along with hydrating the Suspense boundary outside the Activity. await waitForPaint(['HiddenChild']); expect(container).toMatchInlineSnapshot(`
@@ -3766,6 +3776,37 @@ describe('ReactDOMServerPartialHydration', () => { + + + + + + Hidden + +
+ `); + + // Next the child inside the Activity is hydrated. + await waitForPaint(['HiddenChild']); + + expect(container).toMatchInlineSnapshot(` +
+ + Visible + + + + + + + + + Hidden + diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js index b8e753dc03514..41e01b74601e2 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.js @@ -724,7 +724,14 @@ function updateOffscreenComponent( } reuseHiddenContextOnStack(workInProgress); pushOffscreenSuspenseHandler(workInProgress); - } else if (!includesSomeLane(renderLanes, (OffscreenLane: Lane))) { + } else if ( + !includesSomeLane(renderLanes, (OffscreenLane: Lane)) || + // SSR doesn't render hidden content (except legacy hidden) so it shouldn't hydrate, + // even at offscreen lane. Defer to a client rendered offscreen lane. + (getIsHydrating() && + (!enableLegacyHidden || + nextProps.mode !== 'unstable-defer-without-hiding')) + ) { // We're hidden, and we're not rendering at Offscreen. We will bail out // and resume this tree later.