React hook used to notify component unmount
npm install @romain-faust/use-unmountReact hook used to notify component unmount.
_With NPM_:
``bash`
npm install @romain-faust/use-unmount
_With PNPM_:
`bash`
pnpm add @romain-faust/use-unmount
_With Yarn_:
`bash`
yarn add @romain-faust/use-unmount
- @romain-faust/use-singleton (^1.0.2)
- react (>=16.8.6)
- rxjs (^7.5.7)
`tsx
import { useUnmount } from '@romain-faust/use-unmount'
const CreateProductForm = () => {
const unmount$ = useUnmount()
const handleSubmit = (productInfo: ProductInfo) => {
getCurrentUser()
.pipe(map((user) => user.id))
.pipe(mergeMap((ownerId) => createProduct(productInfo, ownerId)))
.pipe(takeUntil(unmount$))
.subscribe((product) => {
navigateToProductDetails(product.id)
})
}
// ...
}
``