Loading...
Please waitLoading...
Please waitRun a function when a component unmounts, ensuring cleanups or final actions are handled effectively.
pnpm dlx uselab@latest add use-unmount
import { useUnmount } from "@/hooks/use-unmount"
export default function Component() {
useUnmount(() => {
// Cleanup logic here
})
return <div>Hello world</div>
}| Name | Type | Description | Default Value | Optional |
|---|---|---|---|---|
Function | () => void | The cleanup function to be executed on unmount. | () => undefined | No |
| Type | Description |
|---|---|
void | A function that runs the cleanup function when the component unmounts. |