Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

MutationState.md

45 lines2.0 KB

1---
2id: MutationState
3title: MutationState
4---
5​
6Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30)
7​
8The raw state stored on a `Mutation` instance. This is the underlying state
9that observer results (e.g. `MutationObserverResult`) are derived from.
10​
11## Extended by
12​
13- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)
14​
15## Type Parameters
16​
17### TData
18​
19`TData` = `unknown`
20​
21### TError
22​
23`TError` = [`DefaultError`](../type-aliases/DefaultError.md)
24​
25### TVariables
26​
27`TVariables` = `unknown`
28​
29### TOnMutateResult
30​
31`TOnMutateResult` = `unknown`
32​
33## Properties
34​
35| Property | Type | Description |
36| ------ | ------ | ------ |
37| <a id="property-context"></a> `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. |
38| <a id="property-data"></a> `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. |
39| <a id="property-error"></a> `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. |
40| <a id="property-failurecount"></a> `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. |
41| <a id="property-failurereason"></a> `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. |
42| <a id="property-ispaused"></a> `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. |
43| <a id="property-status"></a> `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. |
44| <a id="property-submittedat"></a> `submittedAt` | `number` | The timestamp for when the mutation was submitted. |
45| <a id="property-variables"></a> `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. |