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

Function useQueryClient

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

Source from the content-addressed store, hash-verified

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

Callers 13

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

Calls 1

getClientKeyFunction · 0.90

Tested by

no test coverage detected