Skip to content
Discussion options

You must be logged in to vote

There are a couple of things that mutations give you, like:

  • tracking of error and loading state so that you can show a loading spinner / disable a button etc. while the mutation is going on
  • callbacks like onSuccess and onError so that you can invalidate your list query after you've added an entry so that it actually show up in the list
  • an easy way to perform optimistic updates so that you can add the entry to your list query even before the mutation has finished.

For more info, please read https://tkdodo.eu/blog/mastering-mutations-in-react-query

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by buglessir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants