Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,11 @@ describe('ReactDOMServerPartialHydration', () => {
<Activity mode="hidden">
<HiddenChild />
</Activity>
<Suspense fallback={null}>
<Activity mode="hidden">
<HiddenChild />
</Activity>
</Suspense>
</>
);
}
Expand All @@ -3743,6 +3748,10 @@ describe('ReactDOMServerPartialHydration', () => {
</span>
<!--&-->
<!--/&-->
<!--$-->
<!--&-->
<!--/&-->
<!--/$-->
</div>
`);

Expand All @@ -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(`
<div>
Expand All @@ -3766,6 +3776,37 @@ describe('ReactDOMServerPartialHydration', () => {
</span>
<!--&-->
<!--/&-->
<!--$-->
<!--&-->
<!--/&-->
<!--/$-->
<span
style="display: none;"
>
Hidden
</span>
</div>
`);

// Next the child inside the Activity is hydrated.
await waitForPaint(['HiddenChild']);

expect(container).toMatchInlineSnapshot(`
<div>
<span>
Visible
</span>
<!--&-->
<!--/&-->
<!--$-->
<!--&-->
<!--/&-->
<!--/$-->
<span
style="display: none;"
>
Hidden
</span>
<span
style="display: none;"
>
Expand Down
9 changes: 8 additions & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading