State Management · Senior · Question 36 of 75

What does useSWRMutation give compared to calling fetch and then mutate?

Explanation

const { trigger, isMutating } = useSWRMutation('/api/todos', sendRequest) - the request runs only when trigger is called, and the key's cache can be updated with the result. It's SWR's counterpart of useMutation.

Further reading

Problem with a question

State Management · Senior · question 36

Test yourself

Take the State Management · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz