MutationHookOptions
Defined in: react/src/types.ts:866
Options for useMutation hook. Extends React Query’s UseMutationOptions with invalidateQueries support.
Extends
Section titled “Extends”Omit<UseMutationOptions<ReactorReturnOk<Service,Method,Transform>,ReactorReturnErr<Service,Method,Transform>,ReactorArgs<Service,Method,Transform>,TOnMutateResult>,"mutationFn">
Type Parameters
Section titled “Type Parameters”Service
Section titled “Service”Service = BaseActor
Method
Section titled “Method”Method extends FunctionName<Service> = FunctionName<Service>
Transform
Section titled “Transform”Transform extends TransformKey = "candid"
TOnMutateResult
Section titled “TOnMutateResult”TOnMutateResult = unknown
The value onMutate returns, which onSuccess,
onError and onSettled receive. TypeScript infers it from onMutate.
Properties
Section titled “Properties”invalidateQueries?
Section titled “invalidateQueries?”
optionalinvalidateQueries?: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.
Example
Section titled “Example”const balanceQuery = getIcpBalance([account])useMutation({ invalidateQueries: [balanceQuery],})onCanisterError?
Section titled “onCanisterError?”
optionalonCanisterError?: (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.
Parameters
Section titled “Parameters”CanisterError<TransformReturnRegistry<ErrResult<ActorMethodReturnType<Service[Method]>>, Service>[Transform]>
The CanisterError containing the typed error value
variables
Section titled “variables”ReactorArgs<Service, Method, Transform>
The arguments passed to the mutation
Returns
Section titled “Returns”void