Skip to content
IC Reactor

MutationHookOptions

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

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?: (readonly unknown[] | undefined)[]

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

Query keys to invalidate upon successful mutation. Use query.getQueryKey() to get the key from a query result.

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

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

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

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