realue • Docs
realue / useFetch
useFetch<
T
,Q
>(fetch
,props
?): [PromiseState
<T
>, (request
?) =>void
]
Handles a single concurrent request and updates the value
or error
through the provided onChange
and onChangeError
callbacks. The callback in the returned tuple enables issuing a new request. If the callback is called with no arguments, it resets the request back to the idle
state, aborting the prior request if it was not fulfilled.
• T
• Q extends unknown
• fetch: Fetch
<T
, Q
> = ...
An optional request fetcher that defaults to using the standard fetch
method.
• props?: NevoProps
<T
>
The optional onChange
and onChangeError
callbacks to notify about the resulting value
or error
, and the name
.
[PromiseState
<T
>, (request
?) => void
]
A tuple consisting of the current request state and a callback to issue a new request.
Use useAsyncProps
instead.