-
in I was expecting isn't that right? see my codesandbox for reproduction. also, if you see my sandbox you'll see |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think the typescript types are a bit misleading. only callbacks on Invalidation should usually happen on the callbacks of |
Beta Was this translation helpful? Give feedback.
-
@TkDodo, I found your example very helpful specially for awaiting on refetch-
So, here as I am return invalidation request from onSuccess, it wait to resolving refetch. All is working. IsPending also stayed true while refetching. So, I think, I will show a toast message or redirect the page after completing mutation as well as refetching. I am not finding callback function in useMutation to getting know there is complete state with mutation as well as refetching. So you have any idea? |
Beta Was this translation helpful? Give feedback.
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