ActionResult

type ActionResult<TArgs, TResult> = object;

Reactive state and controls for an async action managed by useAction (and plugin-specific hooks built on top of it).

Lifecycle: starts at idle. Each send(...) flips to running, then to success or error depending on the outcome. data from a prior success persists through subsequent running states for stale-while-revalidate UX; only reset() clears it.

Calling send(...) while a previous call is in flight aborts the first via its AbortSignal and replaces it. Awaiters of the superseded call see a rejection with an AbortError, filterable via isAbortError from @solana/promises.

Type Parameters

Type ParameterDescription
TArgs extends readonly unknown[]The argument tuple send accepts; forwarded to the wrapped function after the abort signal.
TResultThe value the wrapped function resolves to on success.

Properties

data

data: TResult | undefined;

The result on success, or undefined if no successful call has happened yet.


error

error: unknown;

The error on failure, or undefined.


isError

isError: boolean;

true when status === 'error'.


isIdle

isIdle: boolean;

true when status === 'idle'.


isRunning

isRunning: boolean;

true when status === 'running' — a send is in flight.


isSuccess

isSuccess: boolean;

true when status === 'success'.


reset()

reset: () => void;

Reset state back to idle, aborting any in-flight call. Stable reference.

Returns

void


send()

send: (...args) => Promise<TResult>;

Trigger the action. Resolves with the wrapped function's result, or rejects with the thrown error. Calling send again while a prior call is in flight aborts the first and rejects its promise with an AbortError. Stable reference.

Fire-and-forget callers can ignore the returned promise and render from status / data / error. Awaiters that read the resolved value (e.g. to navigate on success) should filter supersede rejections with isAbortError from @solana/promises.

Parameters

ParameterType
...argsTArgs

Returns

Promise<TResult>


status

status: "error" | "idle" | "running" | "success";

The current lifecycle status as a discriminated string. The isIdle / isRunning / isSuccess / isError booleans below are derived from this — pick whichever reads better at the call site.

On this page