Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

QueryObserverOptions

interface QueryObserverOptions <TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey> {
_optimisticResults?: "optimistic" | "isRestoring";
enabled?: boolean;
keepPreviousData?: boolean;
notifyOnChangeProps?: NotifyOnChangeProps;
onError?: (err: TError) => void;
onSettled?: (data: TData | undefined, error: TError | null) => void;
onSuccess?: (data: TData) => void;
placeholderData?: TQueryData | PlaceholderDataFunction<TQueryData>;
refetchInterval?: number | false | ((data: TData | undefined, query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => number | false);
refetchIntervalInBackground?: boolean;
refetchOnMount?: boolean | "always" | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | "always");
refetchOnReconnect?: boolean | "always" | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | "always");
refetchOnWindowFocus?: boolean | "always" | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | "always");
retryOnMount?: boolean;
select?: (data: TQueryData) => TData;
staleTime?: number;
suspense?: boolean;
useErrorBoundary?: UseErrorBoundary<TQueryFnData, TError, TQueryData, TQueryKey>;
}

§Type Parameters

§
TQueryFnData = unknown
[src]
§
TError = unknown
[src]
§
TData = TQueryFnData
[src]
§
TQueryData = TQueryFnData
[src]
§
TQueryKey extends QueryKey = QueryKey
[src]

§Extends

§
QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey>
[src]

§Properties

§
_optimisticResults?: "optimistic" | "isRestoring"
[src]
§
enabled?: boolean
[src]

Set this to false to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the refetch method returned from the useQuery instance. Defaults to true.

§
keepPreviousData?: boolean
[src]

Set this to true to keep the previous data when fetching based on a new query key. Defaults to false.

§
notifyOnChangeProps?: NotifyOnChangeProps
[src]

If set, the component will only re-render if any of the listed properties change. When set to ['data', 'error'], the component will only re-render when the data or error properties change. When set to 'all', the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.

§
onError?: (err: TError) => void
[src]

This callback will fire if the query encounters an error and will be passed the error.

§
onSettled?: (data: TData | undefined, error: TError | null) => void
[src]

This callback will fire any time the query is either successfully fetched or errors and be passed either the data or error.

§
onSuccess?: (data: TData) => void
[src]

This callback will fire any time the query successfully fetches new data.

§
placeholderData?: TQueryData | PlaceholderDataFunction<TQueryData>
[src]

If set, this value will be used as the placeholder data for this particular query observer while the query is still in the loading data and no initialData has been provided.

§
refetchInterval?: number | false | ((data: TData | undefined, query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => number | false)
[src]

If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency Defaults to false.

§
refetchIntervalInBackground?: boolean
[src]

If set to true, the query will continue to refetch while their tab/window is in the background. Defaults to false.

§
refetchOnMount?: boolean | "always" | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | "always")
[src]

If set to true, the query will refetch on mount if the data is stale. If set to false, will disable additional instances of a query to trigger background refetches. If set to 'always', the query will always refetch on mount. If set to a function, the function will be executed with the latest data and query to compute the value Defaults to true.

§
refetchOnReconnect?: boolean | "always" | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | "always")
[src]

If set to true, the query will refetch on reconnect if the data is stale. If set to false, the query will not refetch on reconnect. If set to 'always', the query will always refetch on reconnect. If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to the value of networkOnline (true)

§
refetchOnWindowFocus?: boolean | "always" | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | "always")
[src]

If set to true, the query will refetch on window focus if the data is stale. If set to false, the query will not refetch on window focus. If set to 'always', the query will always refetch on window focus. If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to true.

§
retryOnMount?: boolean
[src]

If set to false, the query will not be retried on mount if it contains an error. Defaults to true.

§
select?: (data: TQueryData) => TData
[src]

This option can be used to transform or select a part of the data returned by the query function.

§
staleTime?: number
[src]

The time in milliseconds after data is considered stale. If set to Infinity, the data will never be considered stale.

§
suspense?: boolean
[src]

If set to true, the query will suspend when status === 'loading' and throw errors when status === 'error'. Defaults to false.

§
useErrorBoundary?: UseErrorBoundary<TQueryFnData, TError, TQueryData, TQueryKey>
[src]

Whether errors should be thrown instead of setting the error property. If set to true or suspense is true, all errors will be thrown to the error boundary. If set to false and suspense is false, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (true) or return the error as state (false). Defaults to false.