fix(react-router): render the pending document root only when its beforeLoad context exists - #8129
Conversation
…oreLoad context exists The document-root pending exception keeps rendering the real component because pending UI would remove <html> and hydrated matches retain their prior data. An uncommitted hydrated root has no prior data: hydrate() only merges the dehydrated beforeLoad context (b) for committed matches, so an id-mismatched or stale root renders with every beforeLoad-provided context key missing (TanStack#8115's production symptom, still present with TanStack#8116). Track beforeLoad settlement on the client (__beforeLoadContext, mirroring load-server) and via the dehydrated b for committed hydration, and gate the document-root exception on it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe router now stores and restores ChangesHydration context handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized hydration fix is merge-ready after normal checks and review; no actionable merge-blocking risk remains. Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #8128
Summary
contextualize(router-core) records__beforeLoadContextwhen a clientbeforeLoadsettles, mirroringload-server(a void return records{}, so it still counts as settled)hydrate()restores__beforeLoadContextfrom the dehydratedbfor committed matchesMatch.tsx's document-root pending exception renders the real component only when the route has nobeforeLoador the match's beforeLoad contribution exists — the condition the branch's own comment ("hydrated matches retain their prior data") already assumes['undefined', 'en']without this change,['en']with itVerification
mainand on fix(router-core): keep a reloading match's previous beforeLoad context until it settles #8116's branch (this window opens beforecontextualizeruns, so fix(router-core): keep a reloading match's previous beforeLoad context until it settles #8116 can't close it), passes hereMatch.tsxgate is React-specific); start-client-core: 88/88 runtime tests (its typecheck needs sibling packages not built in my environment, unrelated)ssr: falseshell routeSummary by CodeRabbit
Bug Fixes
Tests