Skip to content
Source
Sign inSign up
TanStack/router

fix(react-start-client): call HydrationBoundary hooks before the visible() gate #8653

Mergedethan-huo(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/8653/headmerged by Sheraff(GitHub profile, opens in a new tab)

Showing 3 changed files with 103 additions and 9 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/visible-hydrate-replay.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/react-start-client': patch
+---
+​
+fix: a `visible()` boundary keeps its server HTML when the intersection arrives while React waits to replay the boundary's render
10 additions and 8 deletionspackages/react-start-client/src/hydration/visible.tsxModified
View file
@@ -26,20 +26,22 @@
o?: () => void
children?: React.ReactNode
}) {
- const { g, o } = props
+ // Above the gate: a replay after `use` suspended can find the gate open and
+ // skip `use`, and only `use` leaves the replay's dispatcher, which rejects a
+ // hook the first attempt did not reach.
+ const { o } = props
+ React.useEffect(() => {
+ o?.()
+ }, [o])
​
- if (!g.r) {
+ if (!props.g.r) {
if (!reactUse) {
- throw g.p