best practices passing path params to RQ useMutation hook #6069
Unanswered
crisfcodes
asked this question in
Q&A
Replies: 2 comments
-
generally speaking, it's much easier to have all the params as close as possible to the mutation. so your second example is much better. there's no reason to force yourself to make |
Beta Was this translation helpful? Give feedback.
0 replies
-
my rule of thumb is: if |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
I created a hook that will use a react-query
useMutation
behind the scenes, the hook will receive an ID to be used in the request like so:usually, I will pass the ID directly in the execution of
useMyHook
The thing is, the ID should be retrieved with an asynchronous process, so should I pass the ID in themutate
payload or should I handle the ID in aReact.state
and pass the value touseMyHook
?Using React.state
Using the payload
Beta Was this translation helpful? Give feedback.
All reactions