Skip to content

Latest commit

 

History

History
41 lines (21 loc) · 1.35 KB

useFetch.md

File metadata and controls

41 lines (21 loc) · 1.35 KB

realueDocs


realue / useFetch

Function: 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.

Type Parameters

T

Q extends unknown

Parameters

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.

Returns

[PromiseState<T>, (request?) => void]

A tuple consisting of the current request state and a callback to issue a new request.

Deprecated

Use useAsyncProps instead.

Defined in

lib/hooks/useFetch.ts:21