-
-
Couldn't load subscription status.
- Fork 1.3k
feat: Export useHydrated hook with documentation #5645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The useHydrated hook is now exported from both react-router and solid-router ClientOnly modules and re-exported in their respective index files. This allows consumers to directly import useHydrated for hydration state detection.
Introduced documentation for the useHydrated hook in both React and Solid execution model guides. The new sections explain how to use the hook for hydration-dependent behavior, including example usage and details on its SSR and client behavior.
WalkthroughExports the existing internal Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Server
participant Client
participant useHydrated
rect rgba(200,230,255,0.3)
Note over Server,Client: Server-side render
Server->>Client: HTML (SSR)\n(useHydrated = false)
end
rect rgba(255,245,200,0.3)
Note over Client,useHydrated: First client render (pre-hydration)
Client->>useHydrated: read()
useHydrated-->>Client: false
end
rect rgba(200,255,210,0.3)
Note over Client,useHydrated: Hydration completes
Client->>useHydrated: subscription/hydrate event
useHydrated-->>Client: true
end
Note over Client: Subsequent renders
Client->>useHydrated: read()
useHydrated-->>Client: true
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
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 |
Replaces the interactive button example with a timezone display in both React and Solid execution model guides. Updates the explanation to emphasize conditional rendering based on client-side data, providing a clearer use case for hydration-dependent behavior.
|
View your CI Pipeline Execution ↗ for commit 464faf6
☁️ Nx Cloud last updated this comment at |
Overview
Exports the
useHydratedhook for both React and Solid Router, making it publicly available for developers to use in their applications. Previously, this hook was only used internally by theClientOnlycomponent.Changes
useHydratedfrom@tanstack/react-routeruseHydratedfrom@tanstack/solid-routerWhat is
useHydrated?A hook that returns a boolean (React) or accessor (Solid) indicating whether client-side JavaScript has been hydrated. This is useful for:
Behavior
falsefalsetrue(persistent)Documentation
Added sections in both framework guides:
docs/start/framework/react/guide/execution-model.mddocs/start/framework/solid/guide/execution-model.mdExample Usage
React:
Solid:
This pattern allows components to render safely on the server with a fallback value (UTC) and then show the actual client timezone after hydration, avoiding hydration mismatches.
Summary by CodeRabbit
New Features
Documentation
Chores