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

Function fetchState

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

Source from the content-addressed store, hash-verified

1045 * @returns The partial query state for a starting fetch.
1046 */
1047export function fetchState<
1048 TQueryFnData,
1049 TError,
1050 TData,
1051 TQueryKey extends QueryKey,
1052>(
1053 data: TData | undefined,
1054 options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
1055) {
1056 return {
1057 fetchFailureCount: 0,
1058 fetchFailureReason: null,
1059 fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused',
1060 ...(data === undefined &&
1061 ({
1062 error: null,
1063 status: 'pending',
1064 } as const)),
1065 } as const
1066}
1067
1068/**
1069 * Returns the state changes applied when a query receives data.

Callers 2

createResultMethod · 0.90
reducerMethod · 0.85

Calls 1

canFetchFunction · 0.90

Tested by

no test coverage detected