Open History to see the last commit
1---
2id: useQueries
3title: useQueries
4---
5β
6The `useQueries` hook can be used to fetch a variable number of queries:
7β
8```tsx
9const results = useQueries({
10 queries: [
11 { queryKey: ['post', 1], queryFn: fetchPost, staleTime: Infinity },
12 { queryKey: ['post', 2], queryFn: fetchPost, staleTime: Infinity },
13 ],
14})
15```
16β
17**Options**
18β
19The `useQueries` hook accepts an options object with a **queries** key whose value is an array with query option objects identical to the [`useQuery` hook](../../../../framework/react/reference/useQuery) (excluding the `context` option).
20β
21- `context?: React.Context<QueryClient | undefined>`
22 - Use this to use a custom React Query context. Otherwise, `defaultContext` will be used.
23β
24> Having the same query key more than once in the array of query objects may cause some data to be shared between queries, e.g. when using `placeholderData` and `select`. To avoid this, consider de-duplicating the queries and map the results back to the desired structure.
25β
26**Returns**
27β
28The `useQueries` hook returns an array with all the query results. The order returned is the same as the input order.