1.2.0 • Published 1 year ago

@romain-faust/use-unmount v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@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

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)
            })
    }

    // ...
}

License

MIT

1.2.0

1 year ago

1.1.0

2 years ago

1.0.0

2 years ago