MCPcopy Index your code
hub / github.com/TanStack/query / getQueryData

Method getQueryData

packages/query-core/src/queryClient.ts:129–138  ·  view source on GitHub ↗

* Imperative (non-reactive) way to retrieve data for a QueryKey. * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. * * Hint: Do not use this function inside a component, because it won't receive updates. * Use `useQue

(queryKey: TTaggedQueryKey)

Source from the content-addressed store, hash-verified

127 * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
128 */
129 getQueryData<
130 TQueryFnData = unknown,
131 TTaggedQueryKey extends QueryKey = QueryKey,
132 TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
133 >(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined {
134 const options = this.defaultQueryOptions({ queryKey })
135
136 return this.#queryCache.get<TInferredQueryFnData>(options.queryHash)?.state
137 .data
138 }
139
140 ensureQueryData<
141 TQueryFnData,

Callers 13

ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
streamedQueryFunction · 0.45
utils.test-d.tsxFile · 0.45
query.test.tsxFile · 0.45

Calls 2

defaultQueryOptionsMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected