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

useSuspenseQueries.md

35 lines1.3 KB

const result = useSuspenseQueries(options)

Options

The same as for useQueries, except that each query can't have:

  • throwOnError
  • enabled

placeholderData is supported, but its callback does not receive information from previously rendered Queries. This matches useQueries, because the number and order of Queries can change between renders.

The select typing caveat for useQueries applies here as well: annotate the select parameter or use the queryOptions helper to keep type inference.

Returns

Same structure as useQueries, except that for each query:

  • data is guaranteed to be defined
  • status is either success or error
    • the derived flags are set accordingly.

Each result includes isPlaceholderData.

Caveats

Keep in mind that the component will only re-mount after all queries have finished loading. Hence, if a query has gone stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid this, make sure to set a high enough staleTime.

Cancellation does not work.