useMudation allows you call a defined mutation (via createMutation)
to trigger and action for usage within your React component.
Mutations's have built in support for Suspense and Error Boundaries with no extra effort.
To use a mutation call the mutate method from the return Object.
The data property is a mirrored store of the query associated with the mutation.
The status property is the state associated with the mutation when triggered.
useMutation accepts the following options:
| Params | Required | Description |
|---|---|---|
MutationTuple | true | The result of the mutation defined. |
useMutation returns and Object with the following options:
| Property | Type | Description |
|---|---|---|
mutate | (variables: V) => Promise<T> | A function that calls the defined mutation Promise. |
data | T | undefined | The cached state of the query associated with it. |
error | unknown | undefined | The error thrown from the mutation. |
status | MutationStatus | The Promise-based status state of the mutation. |
"idle"
{
"id": "",
"name": ""
}{
"id": "",
"name": ""
}{
"id": "",
"name": ""
}