(queryClient?: QueryClient)
| 26 | * component tree. |
| 27 | */ |
| 28 | export const useQueryClient = (queryClient?: QueryClient) => { |
| 29 | if (queryClient) { |
| 30 | return queryClient |
| 31 | } |
| 32 | const client = useContext(QueryClientContext) |
| 33 | |
| 34 | if (!client) { |
| 35 | throw new Error(queryClientContextError) |
| 36 | } |
| 37 | |
| 38 | return client() |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Resolves the `QueryClient` to use: the given one, or else the one from the nearest |