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

MutationObserverLoadingResult.md

50 lines4.4 KB

1---
2id: MutationObserverLoadingResult
3title: MutationObserverLoadingResult
4---
5​
6Defined in: [packages/query-core/src/types.ts:2201](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2201)
7​
8A mutation result in the `pending` state while the mutation runs.
9​
10## Extends
11​
12- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>
13​
14## Type Parameters
15​
16### TData
17​
18`TData` = `unknown`
19​
20### TError
21​
22`TError` = [`DefaultError`](../type-aliases/DefaultError.md)
23​
24### TVariables
25​
26`TVariables` = `void`
27​
28### TOnMutateResult
29​
30`TOnMutateResult` = `unknown`
31​
32## Properties
33​
34| Property | Type | Description | Overrides |
35| ------ | ------ | ------ | ------ |
36| <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. | - |
37| <a id="property-data"></a> `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) |
38| <a id="property-error"></a> `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) |
39| <a id="property-failurecount"></a> `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - |
40| <a id="property-failurereason"></a> `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - |
41| <a id="property-iserror"></a> `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) |
42| <a id="property-isidle"></a> `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) |
43| <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. | - |
44| <a id="property-ispending"></a> `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) |
45| <a id="property-issuccess"></a> `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) |
46| <a id="property-mutate"></a> `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - |
47| <a id="property-reset"></a> `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - |
48| <a id="property-status"></a> `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) |
49| <a id="property-submittedat"></a> `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - |
50| <a id="property-variables"></a> `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) |