Performing Data Mutations with React Query
When building applications, you won’t always need to fetch data. Sometimes, you will want to create, update, or delete it. When doing these actions, your server state will have to change.
React Query allows you to change your server state by using mutations. To perform mutations, you can leverage another of React Query’s custom hooks, called useMutation
.
In this chapter, you will be introduced to the useMutation
hook and understand how React Query allows you to create, update, and delete your server state. Similar to Chapter 4, during this process, you will learn about all the defaults used in your mutations. You will also be introduced to some options you can use to improve your useMutation
experience.
Once you are familiar with useMutation
, you will get to know how you can leverage some of its options to perform some side-effect patterns, such as manually updating your data or forcing a query to update after performing...