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

IsRestoringProvider.ts

18 lines762 Bytes

1'use client'
2import * as React from 'react'
3​
4const IsRestoringContext = React.createContext(false)
5​
6/**
7 * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
8 * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
9 * race conditions between the restore and mounting queries.
10 * @returns `true` while a persisted client is being restored, `false` otherwise.
11 */
12export const useIsRestoring = () => React.useContext(IsRestoringContext)
13​
14/**
15 * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently
16 * being restored, read by `useIsRestoring`.
17 */
18export const IsRestoringProvider = IsRestoringContext.Provider