1.0.0 • Published 4 years ago

use-unmount v1.0.0

Weekly downloads
9
License
Unlicense
Repository
github
Last release
4 years ago

use-unmount

React hook that returns a single RxJS observable, which emits once true when the component un-mounts.

Install

yarn add use-unmount

Use

import {useUnmount$} from 'use-unmount';

const Component = () => {
  const unmount$ = useUnmount$();

  const onClick = () => {
    createUser$({name})
      .pipe(takeUntil(unmount$))
      .subscribe(() => { /* ... */ });
  };
};

License

Unlicense public domain.