MCPcopy Create free account
hub / github.com/TanStack/query / useQueryClient

Function useQueryClient

packages/react-query/src/QueryClientProvider.tsx:21–33  ·  view source on GitHub ↗
(queryClient?: QueryClient)

Source from the content-addressed store, hash-verified

19 * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
20 */
21export const useQueryClient = (queryClient?: QueryClient) => {
22 const client = React.useContext(QueryClientContext)
23
24 if (queryClient) {
25 return queryClient
26 }
27
28 if (!client) {
29 throw new Error('No QueryClient set, use QueryClientProvider to set one')
30 }
31
32 return client
33}
34
35/**
36 * The props accepted by `QueryClientProvider`.

Callers 15

Example6Function · 0.90
Example7Function · 0.90
Example8Function · 0.90
Example9Function · 0.90
Example10Function · 0.90
Example6Function · 0.90
Example7Function · 0.90
Example8Function · 0.90
Example9Function · 0.90
Example10Function · 0.90
WithKnownParametersFunction · 0.90
WithIdentifiersFunction · 0.90

Calls

no outgoing calls

Tested by 1

PageFunction · 0.40