Skip to content
IC Reactor

MutationConfig

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

Configuration for createMutation and useActorMutation.

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.

functionName: Method

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

The method to call on the canister


optional callConfig?: CallConfig

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

Call configuration for the actor method


optional invalidateQueries?: (readonly unknown[] | undefined)[]

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

Queries to invalidate upon successful mutation.

undefined entries are skipped, so the common [maybeQuery?.getQueryKey()] idiom is safe when the optional query object is absent.


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

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

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

This is separate from onError which handles all errors including network failures, agent errors, etc.

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

createMutation(reactor, {
functionName: "transfer",
onCanisterError: (error, variables) => {
// error.err contains the typed Err value
// error.code contains the variant key (e.g., "InsufficientFunds")
console.error(`Transfer failed: ${error.code}`, error.err)
},
})