Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

useHydrate.ts

15 lines384 Bytes

1import { hydrate } from '@tanstack/query-core'
2import { useQueryClient } from './useQueryClient.js'
3import type { HydrateOptions, QueryClient } from '@tanstack/query-core'
4​
5export function useHydrate(
6 state?: unknown,
7 options?: HydrateOptions,
8 queryClient?: QueryClient,
9) {
10 const client = useQueryClient(queryClient)
11​
12 if (state) {
13 hydrate(client, state, options)
14 }