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

Function fetchState

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

Source from the content-addressed store, hash-verified

716}
717
718export function fetchState<
719 TQueryFnData,
720 TError,
721 TData,
722 TQueryKey extends QueryKey,
723>(
724 data: TData | undefined,
725 options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
726) {
727 return {
728 fetchFailureCount: 0,
729 fetchFailureReason: null,
730 fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused',
731 ...(data === undefined &&
732 ({
733 error: null,
734 status: 'pending',
735 } as const)),
736 } as const
737}
738
739function successState<TData>(data: TData | undefined, dataUpdatedAt?: number) {
740 return {

Callers 2

createResultMethod · 0.90
reducerMethod · 0.85

Calls 1

canFetchFunction · 0.90

Tested by

no test coverage detected