1.0.0 • Published 4 years ago
react-generic-use-async v1.0.0
Use Async Hook
A simple utility hook to execute asynchronous code within a React component, heavily inspired by Apollo hooks. The hook itself returns loading
, error
and value
states for the executed function, and a retry method. These can all be destructured from the hook like so:
const [{ loading, error, value }, retry] = useAsync(() => Promise.resolve(true));
1.0.0
4 years ago