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

useQueries.md

26 lines728 Bytes

The useQueries hook can be used to fetch a variable number of queries:

const results = useQueries({
  queries: [
    { queryKey: ['post', 1], queryFn: fetchPost },
    { queryKey: ['post', 2], queryFn: fetchPost }
  ]
})

Options

The useQueries hook accepts an options object with a queries key whose value is an array with query option objects identical to the useQuery hook (excluding the context option).

  • context?: React.Context<QueryClient | undefined>
    • Use this to use a custom React Query context. Otherwise, defaultContext will be used.

Returns

The useQueries hook returns an array with all the query results.