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
Argument | Description | Type | DefaultValue |
---|---|---|---|
fn | clear function | () => void (Required) | - |