Skip to content
Discussion options

You must be logged in to vote

This is on purpose. the callbacks on .mutate are observer level callbacks, and if you call mutate twice, the first observer will unsubscribe, which means you'll only get data / error for the second call (there is only one mutation after all), and the callbacks will only be invoked for the last one. However, the callbacks on useMutation are cache-level callbacks, so they are always called, even if there is no observer.

You can read more about this here: https://tkdodo.eu/blog/mastering-mutations-in-react-query#some-callbacks-might-not-fire

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
2 replies
@ryanmk54
Comment options

@TkDodo
Comment options

Answer selected by ryanmk54
Comment options

You must be logged in to vote
9 replies
@TkDodo
Comment options

@jedzej
Comment options

@TkDodo
Comment options

@jedzej
Comment options

@TkDodo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants