Skip to content

await onSuccess for a mutation #3397

Answered by TkDodo
chiptus asked this question in Q&A
Mar 15, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

I think the typescript types are a bit misleading. only callbacks on useMutation are awaited - the ones on .mutate are not. The reason is that .mutate can be called multiple times.

Invalidation should usually happen on the callbacks of useMutation. I have some explanations here:
https://tkdodo.eu/blog/mastering-mutations-in-react-query#some-callbacks-might-not-fire

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@chiptus
Comment options

Answer selected by chiptus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants