State Management · Senior · Question 36 of 75
What does useSWRMutation give compared to calling fetch and then mutate?
- ✓Correct answer: A
triggerfunction withisMutating/errorstate tied to a key - 2It automatically retries the request forever
- 3It runs the mutation on every render
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.