Performing side-effect patterns after mutations
As you read this section title, you might have been wondering whether you’ve seen how to perform side effects after your mutations previously. The answer is yes, you already did. To perform side effects after a mutation, you can leverage any of these options:
onMutate
onSuccess
onError
onSettled
Now, what you haven’t seen is how you can leverage these side effects to do some amazing things that might improve your user experience, such as performing multiple side effects, refetching a query, or even updating your query data after a mutation.
In this section, we will review some ways we leverage the callback functions of our useMutation
hook and more to perform the previously mentioned side effects.
How to perform an additional side effect
During development, a scenario may come up where it would be useful if you could perform two onSuccess
callbacks. Now, you can definitely add as much...