TanStack · Pipe
onMutate
Optimistic updates change cached query data before a mutation finishes. Save the old data for rollback, then invalidate the query after success or failure.
Last updated
Syntax
useMutation(mutationFn, { onMutate, onError, onSettled })In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
useMutationonMutateonErroronSettleduseQueryClientcancelQueriesgetQueryDatasetQueryData