Skip to content

API Documentation / @pinia/colada / UseMutationReturn

Interface: UseMutationReturn<TData, TVars, TError, TContext> ​

Extends ​

  • UseMutationEntryExtensions<TData, TVars, TError, TContext>

Type Parameters ​

TData ​

TData

TVars ​

TVars

TError ​

TError

TContext ​

TContext extends Record<any, any> = _EmptyObject

Properties ​

asyncStatus ​

ts
asyncStatus: ShallowRef<AsyncStatus>;

Status of the mutation. Becomes 'loading' while the mutation is being fetched, is 'idle' otherwise.


data ​

ts
data: ShallowRef<TData | undefined>;

The result of the mutation. undefined if the mutation has not been called yet.


dataUpdatedAt ​

ts
dataUpdatedAt: ShallowRef<number>;

Timestamp of when data was last successfully returned. TanStack Query compatible property.

Inherited from ​

ts
UseMutationEntryExtensions.dataUpdatedAt

error ​

ts
error: ShallowRef<TError | null>;

The error of the mutation. null if the mutation has not been called yet or if it was successful.


errorUpdatedAt ​

ts
errorUpdatedAt: ShallowRef<number>;

Timestamp of when an error last occurred. TanStack Query compatible property.

Inherited from ​

ts
UseMutationEntryExtensions.errorUpdatedAt

isDelaying ​

ts
isDelaying: ShallowRef<boolean>;

Returns whether the mutation is currently delaying its asyncStatus from becoming 'loading'. Requires the PiniaColadaDelay or PiniaColadaDelayMutations plugin.

Inherited from ​

ts
UseMutationEntryExtensions.isDelaying

isError ​

ts
isError: ComputedRef<boolean>;

Whether the mutation status is 'error'. TanStack Query compatible property.

Inherited from ​

ts
UseMutationEntryExtensions.isError

isIdle ​

ts
isIdle: ComputedRef<boolean>;

Whether the mutation has never been called (status is 'pending' and asyncStatus is 'idle'). TanStack Query compatible property.

Inherited from ​

ts
UseMutationEntryExtensions.isIdle

isLoading ​

ts
isLoading: ComputedRef<boolean>;

Whether the mutation is currently executing.


isPending ​

ts
isPending: ComputedRef<boolean>;

Whether the mutation is currently in progress (asyncStatus === 'loading'). TanStack Query compatible property.

Inherited from ​

ts
UseMutationEntryExtensions.isPending

isSuccess ​

ts
isSuccess: ComputedRef<boolean>;

Whether the mutation status is 'success'. TanStack Query compatible property.

Inherited from ​

ts
UseMutationEntryExtensions.isSuccess

key? ​

ts
optional key?: 
  | EntryKey
  | ((vars) => EntryKey);

mutate ​

ts
mutate: (...args) => void;

Calls the mutation without returning a promise to avoid unhandled promise rejections.

Parameters ​

args ​

...unknown extends TVars ? [] : [TVars]

parameters to pass to the mutation

Returns ​

void


mutateAsync ​

ts
mutateAsync: unknown extends TVars ? () => Promise<TData> : (vars) => Promise<TData>;

Calls the mutation and returns a promise with the result.

Param ​

vars

parameters to pass to the mutation


reset ​

ts
reset: () => void;

Resets the state of the mutation to its initial state.

Returns ​

void


state ​

ts
state: ComputedRef<DataState<TData, TError>>;

The combined state of the mutation. Contains its data, error, and status. It enables type narrowing based on the ['status'].


status ​

ts
status: ShallowRef<DataStateStatus>;

The status of the mutation.

See ​

DataStateStatus


submittedAt ​

ts
submittedAt: ShallowRef<number>;

Timestamp of when the mutation was last submitted. TanStack Query compatible property.

Inherited from ​

ts
UseMutationEntryExtensions.submittedAt

variables ​

ts
variables: ShallowRef<TVars | undefined>;

The variables passed to the mutation. They are initially undefined and change every time the mutation is called.

Released under the MIT License.