@app-elements/use-mount
v0.1.1
Published
A (P)React hook that calls a function after the component is mounted, and possibly when unmounted.
Readme
useDocumentClick
A (P)React hook that calls a function after the component is mounted, and possibly when unmounted.
Installation
npm install --save @app-elements/use-mount
Usage
import { useMount } from '@app-elements/use-mount'
const MyComponent = () => {
useMount(() => alert('MOUNTED'), /* () => alert('UNMOUNTED') */)
return null
}Props
| Prop | Type | Default | Description |
|--------------------|------------|---------------|---------------------|
| onMount | Function | None | Function to invoke on component mount
| onUnmount | Function | None | Function to invoke on component unmount
