# @sevenoutman/use-abandon-on-unmount

> > React Hook for abandoning promises upon component unmounting

Latest version **1.0.1** (published 2019-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sevenoutman/use-abandon-on-unmount
pnpm add @sevenoutman/use-abandon-on-unmount
yarn add @sevenoutman/use-abandon-on-unmount
bun add @sevenoutman/use-abandon-on-unmount
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-11-05 |
| First published | 2019-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Doma |
| Maintainers | sevenoutman |
| Keywords | react, hooks, promise, cancellable, abort |

## Links

- npm: https://www.npmjs.com/package/@sevenoutman/use-abandon-on-unmount
- Repository: https://github.com/SevenOutman/use-abandon-on-unmount
- Issues: https://github.com/SevenOutman/use-abandon-on-unmount/issues
- npm.io page: https://npm.io/package/@sevenoutman/use-abandon-on-unmount

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-11-05
- 1.0.0 — 2019-11-05

## README

# useAbandonOnUnmount

> React Hook for abandoning promises upon component unmounting

    yarn add @sevenoutman/use-abandon-on-unmount

 ## Usage

 ```javascript
 import useAbandonOnUnmount from '@sevenoutman/use-abandon-on-unmount';
 
 function App() {

     const [data, setData] = useState();

     const abandonOnUnmount = useAbandonOnUnmount();

     const fetchData = useCallback(async () => {
         const result = await abandonOnUnmount(requestData());
         setData(result); // Will not excute after this component unmounts
     }, [setData]);

     return (
        // ...
     );
 }
 ```

 ## Why?

Get you rid of this:

     Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.

---
_Source: https://npm.io/package/@sevenoutman/use-abandon-on-unmount · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
