Skip to content

Commit 3ef31d1

Browse files
authored
Implement Partial Hydration for Activity (facebook#32863)
Stacked on facebook#32862 and facebook#32842. This means that Activity boundaries now act as boundaries which can have their effects mounted independently. Just like Suspense boundaries, we hydrate the outer content first and then start hydrating the content in an Offscreen lane. Flowing props or interacting with the content increases the priority just like Suspense boundaries. This skips emitting even the comments for `<Activity mode="hidden">` so we don't hydrate those. Instead those are deferred to a later client render. The implementation are just forked copies of the SuspenseComponent branches and then carefully going through each line and tweaking it. The main interesting bit is that, unlike Suspense, Activity boundaries don't have fallbacks so all those branches where you might commit a suspended tree disappears. Instead, if something suspends while hydration, we can just leave the dehydrated content in place. However, if something does suspend during client rendering then it should bubble up to the parent. Therefore, we have to be careful to only pushSuspenseHandler when hydrating. That's really the main difference. This just uses the existing basic Activity tests but I've started work on port all of the applicable Suspense tests in SelectiveHydration-test and PartialHydration-test to Activity versions.
1 parent 17f88c8 commit 3ef31d1

18 files changed

+5381
-76
lines changed

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -3746,11 +3746,7 @@ describe('ReactDOMServerPartialHydration', () => {
37463746
<span>
37473747
Visible
37483748
</span>
3749-
<!--&-->
3750-
<!--/&-->
37513749
<!--$-->
3752-
<!--&-->
3753-
<!--/&-->
37543750
<!--/$-->
37553751
</div>
37563752
`);
@@ -3766,6 +3762,7 @@ describe('ReactDOMServerPartialHydration', () => {
37663762
// Passive effects.
37673763
await waitForPaint([]);
37683764
}
3765+
37693766
// Subsequently, the hidden child is prerendered on the client
37703767
// along with hydrating the Suspense boundary outside the Activity.
37713768
await waitForPaint(['HiddenChild']);
@@ -3774,11 +3771,7 @@ describe('ReactDOMServerPartialHydration', () => {
37743771
<span>
37753772
Visible
37763773
</span>
3777-
<!--&-->
3778-
<!--/&-->
37793774
<!--$-->
3780-
<!--&-->
3781-
<!--/&-->
37823775
<!--/$-->
37833776
<span
37843777
style="display: none;"
@@ -3796,11 +3789,7 @@ describe('ReactDOMServerPartialHydration', () => {
37963789
<span>
37973790
Visible
37983791
</span>
3799-
<!--&-->
3800-
<!--/&-->
38013792
<!--$-->
3802-
<!--&-->
3803-
<!--/&-->
38043793
<!--/$-->
38053794
<span
38063795
style="display: none;"

0 commit comments

Comments
 (0)