UseReactorMethodParameters
Defined in: react/src/hooks/useActorMethod.ts:52
Configuration for useActorMethod hook. Extends react-query’s QueryObserverOptions with custom reactor params.
This is a unified hook that handles both query and mutation methods. Query-specific options (like refetchInterval) only apply to query methods. Mutation-specific options (like invalidateQueries) only apply to mutation methods.
retry, retryDelay, networkMode and meta decide how a call runs, so
they apply to both. An update method’s call is a mutation: without a retry
here it follows the QueryClient’s mutation defaults, which retry nothing
unless the app set mutations.retry, because each attempt runs the update
on the canister again. Its query defaults, such as reactorRetry, do not
apply to it.
Extends
Section titled “Extends”Omit<QueryObserverOptions<ReactorQueryData<ReactorReturnOk<Service,Method,Transform>>,ReactorReturnErr<Service,Method,Transform>,ReactorQueryData<ReactorReturnOk<Service,Method,Transform>>,ReactorQueryData<ReactorReturnOk<Service,Method,Transform>>,QueryKey>,"queryKey"|"queryFn">
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"
Properties
Section titled “Properties”reactor
Section titled “reactor”reactor:
Reactor<Service,Transform>
Defined in: react/src/hooks/useActorMethod.ts:67
The reactor instance to use for method calls
functionName
Section titled “functionName”functionName:
Method
Defined in: react/src/hooks/useActorMethod.ts:70
The method name to call on the canister
optionalargs?:ReactorArgs<Service,Method,Transform>
Defined in: react/src/hooks/useActorMethod.ts:73
Arguments to pass to the method (optional for parameterless methods)
callConfig?
Section titled “callConfig?”
optionalcallConfig?:CallConfig
Defined in: react/src/hooks/useActorMethod.ts:76
Agent call configuration (effectiveCanisterId, etc.)
queryKey?
Section titled “queryKey?”
optionalqueryKey?: readonlyunknown[]
Defined in: react/src/hooks/useActorMethod.ts:79
Custom query key (auto-generated if not provided)
onSuccess?
Section titled “onSuccess?”
optionalonSuccess?: (data) =>void
Defined in: react/src/hooks/useActorMethod.ts:88
Callback when the method call succeeds. Works for both query and mutation methods.
A method’s undefined result arrives as null, as in useActorQuery,
for query and update methods alike.
Parameters
Section titled “Parameters”ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>
Returns
Section titled “Returns”void
onError?
Section titled “onError?”
optionalonError?: (error) =>void
Defined in: react/src/hooks/useActorMethod.ts:96
Callback when the method call fails. Works for both query and mutation methods.
Parameters
Section titled “Parameters”ReactorReturnErr<Service, Method, Transform>
Returns
Section titled “Returns”void
invalidateQueries?
Section titled “invalidateQueries?”
optionalinvalidateQueries?:InvalidationTarget<Service,Transform>[]
Defined in: react/src/hooks/useActorMethod.ts:111
Queries to invalidate after a successful mutation. Only applies to mutation methods (updates).
Each entry is a query key, a query object or query factory, or a
{ functionName, args? } method of reactor; see
InvalidationTarget. undefined entries are skipped.
The invalidation is awaited before onSuccess runs, as in
useActorMutation and createMutation, so onSuccess sees the
refetched data, and call() resolves once the invalidated queries in use
have refetched.