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

MutationObserverLoadingResult.md

295 lines7.2 KB

Interface: MutationObserverLoadingResult<TData, TError, TVariables, TOnMutateResult>

Defined in: packages/query-core/src/types.ts:1277

Extends

Type Parameters

TData

TData = unknown

TError

TError = DefaultError

TVariables

TVariables = void

TOnMutateResult

TOnMutateResult = unknown

Properties

context

context: TOnMutateResult | undefined;

Defined in: packages/query-core/src/mutation.ts:32

Inherited from

MutationObserverBaseResult.context


data

data: undefined;

Defined in: packages/query-core/src/types.ts:1288

The last successfully resolved data for the mutation.

Overrides

MutationObserverBaseResult.data


error

error: null;

Defined in: packages/query-core/src/types.ts:1290

The error object for the mutation, if an error was encountered.

  • Defaults to null.

Overrides

MutationObserverBaseResult.error


failureCount

failureCount: number;

Defined in: packages/query-core/src/mutation.ts:35

Inherited from

MutationObserverBaseResult.failureCount


failureReason

failureReason: TError | null;

Defined in: packages/query-core/src/mutation.ts:36

Inherited from

MutationObserverBaseResult.failureReason


isError

isError: false;

Defined in: packages/query-core/src/types.ts:1291

A boolean variable derived from status.

  • true if the last mutation attempt resulted in an error.

Overrides

MutationObserverBaseResult.isError


isIdle

isIdle: false;

Defined in: packages/query-core/src/types.ts:1292

A boolean variable derived from status.

  • true if the mutation is in its initial state prior to executing.

Overrides

MutationObserverBaseResult.isIdle


isPaused

isPaused: boolean;

Defined in: packages/query-core/src/mutation.ts:37

Inherited from

MutationObserverBaseResult.isPaused


isPending

isPending: true;

Defined in: packages/query-core/src/types.ts:1293

A boolean variable derived from status.

  • true if the mutation is currently executing.

Overrides

MutationObserverBaseResult.isPending


isSuccess

isSuccess: false;

Defined in: packages/query-core/src/types.ts:1294

A boolean variable derived from status.

  • true if the last mutation attempt was successful.

Overrides

MutationObserverBaseResult.isSuccess


mutate

mutate: MutateFunction<TData, TError, TVariables, TOnMutateResult>;

Defined in: packages/query-core/src/types.ts:1249

The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.

Param

The variables object to pass to the mutationFn.

Param

This function will fire when the mutation is successful and will be passed the mutation's result.

Param

This function will fire if the mutation encounters an error and will be passed the error.

Param

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.

Inherited from

MutationObserverBaseResult.mutate


reset()

reset: () => void;

Defined in: packages/query-core/src/types.ts:1253

A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).

Returns

void

Inherited from

MutationObserverBaseResult.reset


status

status: "pending";

Defined in: packages/query-core/src/types.ts:1295

The status of the mutation.

  • Will be:
    • idle initial status prior to the mutation function executing.
    • pending if the mutation is currently executing.
    • error if the last mutation attempt resulted in an error.
    • success if the last mutation attempt was successful.

Overrides

MutationObserverBaseResult.status


submittedAt

submittedAt: number;

Defined in: packages/query-core/src/mutation.ts:40

Inherited from

MutationObserverBaseResult.submittedAt


variables

variables: TVariables;

Defined in: packages/query-core/src/types.ts:1289

The variables object passed to the mutationFn.

Overrides

MutationObserverBaseResult.variables