Replies: 1 comment 1 reply
-
I don't think it's possible within the rules of react. As you said, you do lots of side-effects, like creating subscriptions and updating options, just inside the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I was looking for a way to simplify the logic of my code that need to perform a dynamic number of queries, without the burden of
useQueries
(for typing reason, and for code clarity).What I mean, is that I was looking for a way to write the code like this:
I tried to write something matching this design, and below I put the corresponding code.
Internally, the
queries
are identified by their keys (using a very rough approach for the POC). New queries are automatically added. Any query that no longer appear in a subsequent render is discarded.That seems to work pretty well, within the limitations of this implementation.
Is something like this already possible with React Query?
Here is the code for the proof of concept. Note that it is not fully compliant with React (because of side effect outside of
useEffect
) and TypeScript (because of theany
s I put here and there).Beta Was this translation helpful? Give feedback.
All reactions