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

Function successState

packages/query-core/src/query.ts:1074–1082  ·  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

1072 * @returns The partial query state for a successful update.
1073 */
1074function successState<TData>(data: TData | undefined, dataUpdatedAt?: number) {
1075 return {
1076 data,
1077 dataUpdatedAt: dataUpdatedAt ?? Date.now(),
1078 error: null,
1079 isInvalidated: false,
1080 status: 'success' as const,
1081 }
1082}
1083
1084/**
1085 * 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