ReactHydration.ts
ReactHydration.ts overview
Section titled “ReactHydration.ts overview”React helpers for applying dehydrated Effect Atom state to a React subtree.
The HydrationBoundary component reads the nearest RegistryContext,
hydrates new Atom values before children render, and delays updates for
existing Atom values until after commit so React transitions do not update
the current UI too early.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”components
Section titled “components”HydrationBoundary
Section titled “HydrationBoundary”Provides a React hydration boundary that loads dehydrated Atom values into the current Atom registry.
When to use
Use to apply dehydrated Atom state to a React subtree that reads from the
nearest RegistryContext.
Details
New Atom values are hydrated during render so descendants can read them immediately, while values for existing Atoms are deferred until after commit so transition data does not update the current UI before React accepts it.
See
Hydration.dehydratefor producing dehydrated Atom stateHydration.hydratefor lower-level non-React hydration
Signature
declare const HydrationBoundary: React.FC<HydrationBoundaryProps>Since v4.0.0
HydrationBoundaryProps (interface)
Section titled “HydrationBoundaryProps (interface)”Props for a boundary that applies dehydrated Atom values to the nearest
RegistryContext while rendering its children.
Signature
export interface HydrationBoundaryProps { state?: Iterable<Hydration.DehydratedAtom> children?: React.ReactNode}Since v4.0.0