Rehooks
Content

useUnmount

A custom React hook that executes a callback function when the component unmounts.

useUnmount

Usage

Component.tsx
import { useUnmount } from "~/hooks/useUnmount";
 
function Component() {
  useUnmount(() => {
    // Do something when the component is unmounted
  });
 
  return <div>Component</div>;
}

API

useUnmount

function useUnmount(fn: () => void): void;

Executes a callback function when the component unmounts.

Parameters

NameTypeDescription
fn() => voidThe callback function to be executed on unmount.

On this page