File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
packages/tanstack-react-query Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff 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
111143A type can be specified for each row returned by ` useQuery` and ` useSuspenseQuery` .
You can’t perform that action at this time.
0 commit comments