Interface MutationObserverIdleResult<TData, TError, TVariables, TContext>

interface MutationObserverIdleResult<TData, TError, TVariables, TContext> {
    context: undefined | TContext;
    data: undefined;
    error: null;
    failureCount: number;
    failureReason: null | TError;
    isError: false;
    isIdle: true;
    isPaused: boolean;
    isPending: false;
    isSuccess: false;
    mutate: MutateFunction<TData, TError, TVariables, TContext>;
    reset: (() => void);
    status: "idle";
    submittedAt: number;
    variables: undefined;
}

Type Parameters

  • TData = unknown
  • TError = DefaultError
  • TVariables = void
  • TContext = unknown

Hierarchy (view full)

Properties

context: undefined | TContext
data: undefined

The last successfully resolved data for the mutation.

error: null

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

  • Defaults to null.
failureCount: number
failureReason: null | TError
isError: false

A boolean variable derived from status.

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

A boolean variable derived from status.

  • true if the mutation is in its initial state prior to executing.
isPaused: boolean
isPending: false

A boolean variable derived from status.

  • true if the mutation is currently executing.
isSuccess: false

A boolean variable derived from status.

  • true if the last mutation attempt was successful.

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.
reset: (() => void)

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

Type declaration

    • (): void
    • Returns void

status: "idle"

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.
submittedAt: number
variables: undefined

The variables object passed to the mutationFn.