Docs
useUnmount
Run a function when a component unmounts, ensuring cleanups or final actions are handled effectively.
Installation
pnpm dlx shadcn@latest add https://hookcn.ouassim.tech/r/use-unmount
Usage
import { useUnmount } from "@/hooks/use-unmount"
export default function Component() {
useUnmount(() => {
// Cleanup logic here
})
return <div>Hello world</div>
}
API Reference
Parameters
Name | Type | Description |
---|---|---|
func | () => void | The cleanup function to be executed on unmount. |
Returns
void