Skip to main content

useUnmount

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

Usage

Live Editor

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

Result
Loading...

API

useUnmount

Returns

void

Arguments

ArgumentDescriptionTypeDefaultValue
fnclear function() => void (Required)-