Optimistic mutations and success side effects #2986
Unanswered
fzaninotto
asked this question in
Q&A
Replies: 1 comment
-
if you want to optimistically re-direct, why not do it right after the
|
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.
-
Hi, and thanks for the awesome library.
I'm exploring optimistic mutations. I want to offer a specialized hook that wraps useMutation and provides optimistic updates. I followed the great doc at https://react-query.tanstack.com/guides/optimistic-updates, and it's working fine, but I have a problem with success side effects.
This is how I'd like my custom hook to be called:
This is how the hook looks like:
In a true optimistic UI, the call time
onSuccess
callback should be triggered right after theonMutate
callback was fired, and not on success (if a redirection occurs after the mutation completes, it's too late). But I can't find a way to do it.Is there a way to read call-time mutationOptions inside the parameters of the options callbacks?
Beta Was this translation helpful? Give feedback.
All reactions