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

Function fetchState

packages/query-core/src/query.ts:710–729  ·  view source on GitHub ↗
(
  data: TData | undefined,
  options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
)

Source from the content-addressed store, hash-verified

708}
709
710export function fetchState<
711 TQueryFnData,
712 TError,
713 TData,
714 TQueryKey extends QueryKey,
715>(
716 data: TData | undefined,
717 options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
718) {
719 return {
720 fetchFailureCount: 0,
721 fetchFailureReason: null,
722 fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused',
723 ...(data === undefined &&
724 ({
725 error: null,
726 status: 'pending',
727 } as const)),
728 } as const
729}
730
731function successState<TData>(data: TData | undefined, dataUpdatedAt?: number) {
732 return {

Callers 2

createResultMethod · 0.90
reducerMethod · 0.85

Calls 1

canFetchFunction · 0.90

Tested by

no test coverage detected