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

Function successState

packages/query-core/src/query.ts:1083–1091  ·  view source on GitHub ↗

* Returns the state changes applied when a query receives data. * @param data - The new data. * @param dataUpdatedAt - The timestamp the data is recorded with. Defaults to the current time. * @returns The partial query state for a successful update.

(data: TData | undefined, dataUpdatedAt?: number)

Source from the content-addressed store, hash-verified

1081 * @returns The partial query state for a successful update.
1082 */
1083function successState<TData>(data: TData | undefined, dataUpdatedAt?: number) {
1084 return {
1085 data,
1086 dataUpdatedAt: dataUpdatedAt ?? Date.now(),
1087 error: null,
1088 isInvalidated: false,
1089 status: 'success' as const,
1090 }
1091}
1092
1093/**
1094 * Returns the initial state of a query, based on its `initialData` and `initialDataUpdatedAt`

Callers 2

setOptionsMethod · 0.85
reducerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected