useUnmount

React lifecycle hook that calls a function when the component will unmount.

Usage

import { useUnmount } from "@reactuses/core";

const Demo = () => {
  const [value] = useState("mounted");
  useUnmount(() => {
    alert("UnMounted");
  });
  return <div>{value}</div>;
};

Example

mounted

Type Declarations

export default function useUnmount(fn: () => void): void