Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

QueryState.md

38 lines2.7 KB

1---
2id: QueryState
3title: QueryState
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8Defined in: [packages/query-core/src/query.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L53)
9​
10The raw state stored on a `Query` instance. This is the underlying state
11that observer results (e.g. `QueryObserverResult`) are derived from.
12​
13## Type Parameters
14​
15### TData
16​
17`TData` = `unknown`
18​
19### TError
20​
21`TError` = [`DefaultError`](../type-aliases/DefaultError.md)
22​
23## Properties
24​
25| Property | Type | Description |
26| ------ | ------ | ------ |
27| <a id="property-data"></a> `data` | `TData` \| `undefined` | The last successfully resolved data for the query. |
28| <a id="property-dataupdatecount"></a> `dataUpdateCount` | `number` | The number of times the query has successfully resolved. |
29| <a id="property-dataupdatedat"></a> `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. |
30| <a id="property-error"></a> `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. |
31| <a id="property-errorupdatecount"></a> `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. |
32| <a id="property-errorupdatedat"></a> `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. |
33| <a id="property-fetchfailurecount"></a> `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. |
34| <a id="property-fetchfailurereason"></a> `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. |
35| <a id="property-fetchmeta"></a> `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. |
36| <a id="property-fetchstatus"></a> `fetchStatus` | `"idle"` \| `"fetching"` \| `"paused"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. |
37| <a id="property-isinvalidated"></a> `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. |
38| <a id="property-status"></a> `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. |