react-generic-use-async

1.0.0 • Public • Published

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));

Dependencies (0)

    Dev Dependencies (14)

    Package Sidebar

    Install

    npm i react-generic-use-async

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    190 kB

    Total Files

    8

    Last publish

    Collaborators

    • tombarton