Skip to content

Commit aa468aa

Browse files
committed
Added useQueries doc entry.
1 parent 1a9f7cf commit aa468aa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/tanstack-react-query/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ export const TodoListDisplaySuspense = () => {
106106
};
107107
```
108108
109+
### useQueries
110+
111+
The `useQueries` hook allows you to run multiple queries in parallel and combine the results into a single result.
112+
113+
```JSX
114+
// TodoListDisplay.jsx
115+
import { useQueries } from '@powersync/tanstack-react-query';
116+
117+
export const TodoListDisplay = () => {
118+
const { data: todoLists } = useQueries({
119+
queries: [
120+
{ queryKey: ['todoLists'], query: 'SELECT * from lists' },
121+
{ queryKey: ['todoLists2'], query: 'SELECT * from lists2' },
122+
],
123+
combine: (results) => {
124+
return {
125+
data: results.map((result) => result.data),
126+
pending: results.some((result) => result.isPending),
127+
}
128+
},
129+
});
130+
131+
return (
132+
<div>
133+
{todoLists.map((list) => (
134+
<li key={list.id}>{list.name}</li>
135+
))}
136+
</div>
137+
);
138+
};
139+
```
140+
109141
### TypeScript Support
110142
111143
A type can be specified for each row returned by `useQuery` and `useSuspenseQuery`.

0 commit comments

Comments
 (0)