Skip to content
IC Reactor

MutationHookOptions

Defined in: react/src/types.ts:866

Options for useMutation hook. Extends React Query’s UseMutationOptions with invalidateQueries support.

Service = BaseActor

Method extends FunctionName<Service> = FunctionName<Service>

Transform extends TransformKey = "candid"

TOnMutateResult = unknown

The value onMutate returns, which onSuccess, onError and onSettled receive. TypeScript infers it from onMutate.

optional invalidateQueries?: InvalidationTarget<Service, Transform>[]

Defined in: react/src/types.ts:893

Queries to invalidate upon successful mutation, after the factory’s own invalidateQueries and before onSuccess. Takes the same entries: a query key, a query object or query factory, or a { functionName, args? } method of the mutation’s reactor; see InvalidationTarget.

const balanceQuery = getIcpBalance([account])
useMutation({
invalidateQueries: [balanceQuery],
})

optional onCanisterError?: (error, variables) => void

Defined in: react/src/types.ts:901

Callback for canister-level business logic errors. Called when the canister returns a Result { Err: E } variant.

CanisterError<TransformReturnRegistry<ErrResult<ActorMethodReturnType<Service[Method]>>, Service>[Transform]>

The CanisterError containing the typed error value

ReactorArgs<Service, Method, Transform>

The arguments passed to the mutation

void