type
PlaceholderData
export type PlaceholderData<TData> =
TData extends (...args: $ReadOnlyArray<empty>) => mixed
? (previous: TData | void) => TData | void
: TData | ((previous: TData | void) => TData | void);
What placeholderData accepts: data of the query's own type, shown before the first answer, or a function that makes that data from the previous answer and may return undefined for "no placeholder".
Typed as the query's TData and not mixed, because the placeholder goes through select exactly like fetched data: a placeholder of another type reached select unchecked. A function always means a producer, so data that is itself a function must be wrapped in a producer.
type
ResolvedQueryOptions
export type ResolvedQueryOptions<TData, TSelected = TData> = {|
readonly queryKey : QueryKey,
readonly queryFn : (context: FetchContext<TData>) => Promise<TData>,
readonly enabled : boolean,
readonly staleTime : number,
readonly gcTime : number,
readonly retry : RetryPolicy,
readonly retryDelay : RetryDelay,
readonly select? : (data: TData) => TSelected,
readonly placeholderData? : PlaceholderData<TData>,
readonly refetchInterval : number | null,
readonly refetchOnWindowFocus: boolean,
readonly refetchOnReconnect : boolean,
|};
The same options with the client's defaults filled in.
type
QueryResult
export type QueryResult<T> = {|
readonly data : T | void,
readonly error : Error | null,
readonly status : QueryStatus,
readonly fetchStatus: FetchStatus,
/** There is no answer yet, not even a failed one. */
readonly isPending: boolean,
/** The first load: pending *and* a request is in flight. */
readonly isLoading: boolean,
readonly isSuccess: boolean,
readonly isError : boolean,
/** A request is in flight, first load or refresh. */
readonly isFetching: boolean,
/** A request is in flight over data that is already on screen. */
readonly isRefetching : boolean,
readonly isStale : boolean,
readonly isPlaceholderData: boolean,
/** Failed attempts in the request in flight, for "retrying (2 of 3)". */
readonly failureCount: number,
/** Refetch now, superseding anything in flight. Never rejects. */
readonly refetch: () => Promise<void>,
|};
What a component sees.
Deliberately without timestamps. A clock reading in a render-visible snapshot re-renders every observer on every successful refresh, even when the answer is identical — which is exactly what structural sharing exists to prevent, and it also defeats select: narrowing to user.name is only worth having if the snapshot is insensitive to the fields it discarded, and a dataUpdatedAt beside it moves whenever *any* field does.
So the snapshot carries decisions rather than readings. isStale is the one the clock reaches, because it is the one a component can act on. client.getQueryState(key) has dataUpdatedAt, checkedAt and the rest for a devtool or a "last updated" label that wants them.