Function: useMutation()
Function: useMutation()
Section titled “Function: useMutation()”useMutation<
M,K>(name):UseMutationResult<M,K>
Defined in: react/src/use-mutation.ts:43
Convenience wrapper around client.mutate(name, args) with pending /
error state suitable for buttons and forms.
const create = useMutation<typeof mutators, "createTodo">("createTodo")...<button disabled={create.isPending} onClick={() => create.mutate({ title })}>Add</button>The mutation returns after the local optimistic apply, so the calling component can dismiss dialogs / clear inputs immediately; the push and subsequent pull happen in the background.
Type Parameters
Section titled “Type Parameters”M
K extends string
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”UseMutationResult<M, K>