RequestResult
Reactive state for a one-shot request managed by useRequest.
Lifecycle: starts at fetching (or disabled when the source is null) and auto-fires on
mount; transitions to success on success or error on failure. refresh() re-fires the
request — while a re-fire is in flight, status returns to fetching and the stale data
and/or error from the prior outcome remain populated (stale-while-revalidate).
Type Parameters
| Type Parameter | Description |
|---|---|
T | The value the underlying request resolves to. |
Properties
data
The most recent successful value, or undefined if no call has succeeded yet (or while
disabled). Persists across subsequent refreshes (including failed ones) until a new success
replaces it or reset() clears the store.
error
The error from the most recent failed call, or undefined if no call has failed (or while
disabled). Persists across subsequent refreshes until a new success clears it. May coexist
with data when a successful attempt is followed by a failing one.
refresh
Re-fire the request. By default each call mints a fresh signal from getAbortSignal (if
configured) and threads it through the underlying store's
withSignal(signal).dispatch(). Pass { abortSignal } to override the configured factory
for just this attempt. Pass { abortSignal: undefined } to opt out of the factory entirely
for this attempt and fire with no caller-provided signal.
Stable reference.
Parameters
| Parameter | Type |
|---|---|
options? | { abortSignal?: AbortSignal; } |
options.abortSignal? | AbortSignal |
Returns
void
status
Lifecycle status as a discriminated string:
fetching: a request is in flight.dataanderrorcarry whatever stale content was available before this attempt (bothundefinedon the first attempt; either or both populated on a refresh after a prior outcome).success: most recent call succeeded;dataholds the result.error: most recent call failed;errorholds the reason.disabled: source wasnull.