react-promise-client
v2.1.0
Published
React hook to handle promises
Downloads
6
Maintainers
Readme
React promise client
This is a lightweight promise handler.
using npm
npm i react-promise-client
In React:
const { data, isLoading, execute } = usePromise({
promiseFn: ()=> asyncAwaitFunction(),
onSuccess results => console.log(results),
onFailure: error => console.log(error);
}, [...deps])
return isLoading? <div>Loading...</div> : <div>done...</div>
- execute: execute promise manually and wait for results in
data
. - data: results from promise call.
- isLoading: true when busy, else false.
- deps: dependencies like any other hook, this is optional