useAsync

Source
import { useAsync } from "@prestojs/util";
useAsync<ResultT,ErrorT = any,ArgsT = any[]>(fn,?options)
Source

Arguments:

ArgumentTypeDescription
*fn
options
An object with the properties below
options.argsArgsT
options.onError
options.onSuccess
options.trigger"MANUAL"|"SHALLOW"|"DEEP"
Returns:
An object with these properties:
PropertyTypeDescription
*errorErrorT|null
*isLoadingboolean
*reset
*responseResultT|null
Deprecated:
*resultResultT|null
*run

Examples

Simple manual usage

Simple automatic usage

useAsync with fetch

useAsync with Endpoint

List & edit view