React-query and support for useQueries #643
-
Is there built in support for the useQueries hook, rather than useQuery with jotai/query? I couldn’t see it. We have a fairly complex use case where the result of several queries (they are actually subscriptions, like a websocket or a streaming grpc connection) need to be transformed, possibly using some combination of optics and/or selectors before passing the result to the UI components. Thanks for the awesome library by the way, the combination of jotai and react-query is very nice indeed |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I assumed useQueries is provided in RQ to avoid violating the rules of hooks. const queryAtom1 = atomWithQuery(...)
const queryAtom2 = atomWithQuery(...)
const queriesAtom = atom((get) => [get(queryAtom1), get(queryAtom2)]) // or whatever shape. can make it writable too. This feels more minimalistic. cc @aulneau |
Beta Was this translation helpful? Give feedback.
I assumed useQueries is provided in RQ to avoid violating the rules of hooks.
Jotai atoms don't have such rules, so we can compose atoms.
This feels more minimalistic.
Does this fill your needs?
(I'm not strongly against providing
atomWithQueries
, if it gives better DX.)cc @aulneau