use-promise
The usePromise hook consumes an asynchronous function is ideal for using fetch or other asynchronous tasks.
Module
import { usePromise } from "@atomico/hooks/use-promise";Syntax
const [result, status] = usePromise(
asyncFunction,
runFunction,
optionalArguments
);Where :
result: Retorno de la promesastatus: Estado de la promesa:"": Without executing."pending": In action."fulfilled": Successfully executed."rejected": Executed with error.
asyncFunction: asynchronous function.runFunction:Booleano, iftrueit will execute the promise and define the status.optionalArguments: Optionalany[], allows to regenerate the promise through arguments.
Example
Last updated
Was this helpful?
