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

Method getQueryState

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

* Imperative (non-reactive) way to retrieve an existing query's state. If the query does not * exist, `undefined` is returned. * @param queryKey - The query key of the query to read. * @returns The query's state, or `undefined` if no query with this key exists. * @example * ```ts *

(
    queryKey: TTaggedQueryKey,
  )

Source from the content-addressed store, hash-verified

373 * ```
374 */
375 getQueryState<
376 TQueryFnData = unknown,
377 TError = DefaultError,
378 TTaggedQueryKey extends QueryKey = QueryKey,
379 TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
380 TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
381 >(
382 queryKey: TTaggedQueryKey,
383 ): QueryState<TInferredQueryFnData, TInferredError> | undefined {
384 const options = this.defaultQueryOptions({ queryKey })
385 return this.#queryCache.get<TInferredQueryFnData, TInferredError>(
386 options.queryHash,
387 )?.state
388 }
389
390 /**
391 * Removes queries from the cache that match the given filters. Unlike

Callers 15

ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
Devtools.test.tsxFile · 0.45
utils.test-d.tsxFile · 0.45

Calls 2

defaultQueryOptionsMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected