useSuspenseQueries
TheuseSuspenseQueries hook is a Suspense-enabled version of useQueries. It suspends rendering until all queries have data and always returns data (never undefined).
Import
Signature
Type Parameters
type
Array type representing the queries configuration
type
default:"SuspenseQueriesResults<T>"
The type of the combined result when using the
combine optionParameters
object
required
Configuration object for the queries
readonly [...SuspenseQueriesOptions<T>]
required
An array of query options. Each query in the array accepts the same options as
useSuspenseQuery.(result: SuspenseQueriesResults<T>) => TCombinedResult
Optional function to combine or select data from all queries. This function is called whenever any query updates.
QueryClient
Optional QueryClient instance to use. If not provided, the context client is used.
Returns
Returns an array of query results (one for each query), or the result of thecombine function if provided. Each query result has the same shape as useSuspenseQuery results:
TData
required
The data for the query. Always defined (never undefined) for suspense queries.
null
Always
null for suspense queries (errors are thrown to error boundaries)'success'
Always
'success' for suspense queriestrue
Always
true for suspense queriesfalse
Always
false for suspense queriesfalse
Always
false for suspense queriesExamples
Basic Usage
With Combine Function
Dynamic Queries
With Error Boundary and Suspense
Notes
skipTokencannot be used with any of the queries inuseSuspenseQueries. If you need conditional fetching, useuseQueriesinstead.- The component will suspend until all queries have loaded their initial data.
- If any query errors, the error is thrown to the nearest error boundary.
- All queries are run in parallel.
- The
enabledoption is always set totruefor all queries and cannot be disabled.