@romain-faust/use-unmount
v1.2.0
Published
React hook used to notify component unmount
Downloads
2
Readme
@romain-faust/use-unmount
React hook used to notify component unmount.
Installation
With NPM:
npm install @romain-faust/use-unmount
With PNPM:
pnpm add @romain-faust/use-unmount
With Yarn:
yarn add @romain-faust/use-unmount
Dependencies
- @romain-faust/use-singleton (^1.0.2)
- react (>=16.8.6)
- rxjs (^7.5.7)
Usage
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)
})
}
// ...
}