mirror of
https://github.com/TanStack/query.git
synced 2026-11-16 22:50:20 +00:00
* docs(query-core): add JSDoc across the package and expose it in generated reference docs * docs(config.json): add sidebar entries for newly generated query-core reference docs * docs(query-core): migrate remaining prose from the legacy 'docs/reference' pages into JSDoc * docs(query-core): remove legacy 'docs/reference' pages superseded by the generated reference * docs(query-core): regenerate reference docs after merging main * docs(query-core): document missing default values for MutationOptions, combine, and QueryFilters.type * fix(query-devtools): drop unnecessary 'query-core' project reference * docs(query-core): document missing default values and normalize 'Defaults to' spacing * docs(query-core): fix 'environmentManager' JSDoc example
1.4 KiB
1.4 KiB
| id | title |
|---|---|
| hydrate | hydrate |
function hydrate(
client,
dehydratedState,
options?): void;
Defined in: packages/query-core/src/hydration.ts:264
Restores a DehydratedState (as produced by dehydrate) into a QueryClient's cache, typically to seed the
client with data already fetched on the server. mutations and queries are each optional on dehydratedState.
Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated
when the dehydrated data is newer than what's already cached. Newly built queries have their fetchStatus reset
to 'idle' so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight
promise, it is resumed via query.fetch() (reusing that promise as initialPromise) rather than re-invoking
queryFn.
Parameters
client
dehydratedState
Partial<DehydratedState>
options?
Returns
void
Example
// dehydratedState was produced by `dehydrate` on the server
// and sent to the client, e.g. embedded in server-rendered markup.
const queryClient = new QueryClient()
hydrate(queryClient, dehydratedState)