Replies: 1 comment 1 reply
-
I don't understand what the switch statement has to do with state and effect. To get rid of the switch statement, you can use the default query function: https://react-query.tanstack.com/guides/default-query-function it would be best if you can create a codesandbox example because I have no idea what the effect is doing / should be doing, or what you mean regarding |
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.
-
For example, I've a switch statement to check type then, fetch the required API:
If I define a query for each request like this:
I have to define specific
state
anduseEffect
for each query...I mean, one state to handle
enabled
anduseEffect
to handle data changes, because{ data }
is not Async and I can't useawait
before that to use it in another functions or somewhere like helper function eg.I think this scenario makes my code unreadable... But what do you think? Is there any way to write it better and readable? or current scenario is better one?
Beta Was this translation helpful? Give feedback.
All reactions