Skip to content

Add AbortController to useAsyncEffect / useEffectOnMount #15

Description

@schwartzworld

In addition to all the other methods, it would be useful to opt out of a request if it's no longer needed. This should happen automatically if the hook unmounts. We might as well also expose a method in the return of the hooks so that a user can manually cancel a request if it's not needed.

const { data, error, loading, fireCallback, abort } = useAsyncEffect(someCallback)

return <div>
    <button onClick={fireCallback}>Make request</button>
    <button onClick={abort}>Abort/button>
</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions