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

QueryObserverBaseResult.md

56 lines5.2 KB

1---
2id: QueryObserverBaseResult
3title: QueryObserverBaseResult
4---
5​
6Defined in: packages/query-core/dist-ts/src/types.d.ts:418
7​
8## Extended by
9​
10- [`QueryObserverPendingResult`](QueryObserverPendingResult.md)
11- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md)
12- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md)
13- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md)
14- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md)
15- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md)
16- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)
17​
18## Type Parameters
19​
20### TData
21​
22`TData` = `unknown`
23​
24### TError
25​
26`TError` = [`DefaultError`](../type-aliases/DefaultError.md)
27​
28## Properties
29​
30| Property | Type | Description |
31| ------ | ------ | ------ |
32| <a id="data"></a> `data` | `TData` \| `undefined` | The last successfully resolved data for the query. |
33| <a id="dataupdatedat"></a> `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. |
34| <a id="error"></a> `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. |
35| <a id="errorupdatecount"></a> `errorUpdateCount` | `number` | The sum of all errors. |
36| <a id="errorupdatedat"></a> `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. |
37| <a id="failurecount"></a> `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. |
38| <a id="failurereason"></a> `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. |
39| <a id="fetchstatus"></a> `fetchStatus` | [`FetchStatus`](../type-aliases/FetchStatus.md) | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. |
40| <a id="isenabled"></a> `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. |
41| <a id="iserror"></a> `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. |
42| <a id="isfetched"></a> `isFetched` | `boolean` | Will be `true` if the query has been fetched. |
43| <a id="isfetchedaftermount"></a> `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. |
44| <a id="isfetching"></a> `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. |
45| <a id="isinitialloading"></a> ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. |
46| <a id="isloading"></a> `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. |
47| <a id="isloadingerror"></a> `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. |
48| <a id="ispaused"></a> `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. |
49| <a id="ispending"></a> `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. |
50| <a id="isplaceholderdata"></a> `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. |
51| <a id="isrefetcherror"></a> `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. |
52| <a id="isrefetching"></a> `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. |
53| <a id="isstale"></a> `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. |
54| <a id="issuccess"></a> `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. |
55| <a id="refetch"></a> `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. |
56| <a id="status"></a> `status` | [`QueryStatus`](../type-aliases/QueryStatus.md) | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. |