#useQueries

6 messages · Page 1 of 1 (latest)

verbal widget
#

Hello,

I have 2 queries which i'm trying to run in Parallel. After having read the docs, it mentioned that i need to use useQueries since i'm using react-query with suspense.

I'm having a hard time adapting my code to useQueries - the syntax is confusing me quite a bit.

In my code, i already have 2 similar custom useQuery wrappers, which look as follows:

export const useTournamentTypes = () =>
    useQuery([queryKeys.tournament_types], getTournamentTypes)
export const useCheckIns = () =>
    useQuery([queryKeys.checkIns], getCheckIns)

How do i pass my 2 custom hooks to useQueries?

Thanks in advance~

pastel bolt
#

just fyi, useQueries doesn't support suspense.

as for syntax, it uses the query object syntax described here: https://tanstack.com/query/v4/docs/reference/useQueries

so it's:

useQueries({ queries: [
  { queryKey: [queryKeys.tournament_types], queryFn: getTournamentTypes },
  { queryKey: [queryKeys.checkIns], queryFn: getCheckIns }
] })

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

`tsx

verbal widget
verbal widget
#

So basically, i cannot really run multiple queries in parallel while using suspense mode and i should disable it instead. I'm not sure if what i'm saying makes sense