API Reference

QueryObserverBaseResult

Defined in: packages/query-core/src/types.ts:962

The properties shared by every state of a query result, like data, error, status, the is* flags, and refetch. Each QueryObserver*Result narrows them for one state.

Extended by

Type Parameters

TData

TData = unknown

TError

TError = DefaultError

Properties

PropertyTypeDescription
dataTData | undefinedThe last successfully resolved data for the query.
dataUpdatedAtnumberThe timestamp for when the query most recently returned the status as "success".
errorTError | nullThe error object for the query, if an error was thrown. - Defaults to null.
errorUpdateCountnumberThe sum of all errors.
errorUpdatedAtnumberThe timestamp for when the query most recently returned the status as "error".
failureCountnumberThe failure count for the query. - Incremented every time the query fails. - Reset to 0 when the query succeeds.
failureReasonTError | nullThe failure reason for the query retry. - Reset to null when the query succeeds.
fetchStatus"idle" | "fetching" | "paused"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 for more information.
isEnabledbooleantrue if this observer is enabled, false otherwise.
isErrorbooleanA derived boolean from the status variable, provided for convenience. - true if the query has an error from a fetch that failed after its retries, or if select threw.
isFetchedbooleanWill be true if the query has been fetched.
isFetchedAfterMountbooleanWill be true if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data.
isFetchingbooleanA derived boolean from the fetchStatus variable, provided for convenience. - true whenever the queryFn is executing, which includes initial pending as well as background refetch.
isInitialLoadingbooleanDeprecated isInitialLoading is being deprecated in favor of isLoading and will be removed in the next major version.
isLoadingbooleanIs true whenever the first fetch for a query is in-flight. - Is the same as isFetching && isPending.
isLoadingErrorbooleanWill be true if the query has an error and no data to display.
isPausedbooleanA derived boolean from the fetchStatus variable, provided for convenience. - The query wanted to fetch, but has been paused.
isPendingbooleanWill be true if the query has no cached data, no data from placeholderData and no error.
isPlaceholderDatabooleanWill be true if the data shown is the placeholder data.
isRefetchErrorbooleanWill be true if the query has an error and still has data to display (for infinite queries, not after a failed page fetch).
isRefetchingbooleanIs true whenever a background refetch is in-flight, which does not include initial pending. - Is the same as isFetching && !isPending.
isStalebooleanWill be true if the data in the cache is invalidated or if the data is older than the given staleTime.
isSuccessbooleanA derived boolean from the status variable, provided for convenience. - true if the query has cached data or data from placeholderData, and no error.
refetch(options?: RefetchOptions) => Promise<QueryObserverResult<TData, TError>>A function to manually refetch the query.
status"error" | "pending" | "success"The status of the query. - Will be: - error if the query has an error from a fetch that failed after its retries, or if select threw. - success if the query has cached data (even if select returns undefined) or data from placeholderData, and no error. - pending otherwise, since the query has no cached data, no data from placeholderData and no error.