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

Function useQueryClient

packages/vue-query/src/useQueryClient.ts:26–44  ·  view source on GitHub ↗
(id = '')

Source from the content-addressed store, hash-verified

24 * ```
25 */
26export function useQueryClient(id = ''): QueryClient {
27 // ensures that `inject()` can be used
28 if (!hasInjectionContext()) {
29 throw new Error(
30 'vue-query hooks can only be used inside setup() function or functions that support injection context.',
31 )
32 }
33
34 const key = getClientKey(id)
35 const queryClient = inject<QueryClient>(key)
36
37 if (!queryClient) {
38 throw new Error(
39 "No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.",
40 )
41 }
42
43 return queryClient
44}

Callers 15

useBaseQueryFunction · 0.90
usePrefetchQueryFunction · 0.90
usePrefetchInfiniteQueryFunction · 0.90
useMutationFunction · 0.90
useIsMutatingFunction · 0.90
useMutationStateFunction · 0.90
useQueriesFunction · 0.90
useIsFetchingFunction · 0.90
useQuery.test.tsFile · 0.90
useQueries.test.tsFile · 0.90

Calls 1

getClientKeyFunction · 0.90

Tested by

no test coverage detected