useUnmount()
The
useUnmount() hook allows you to run a cleanup function right before the component is removed from the DOM. It acts as a semantic alias for the cleanup phase of useEffect(..., []).Import
typescript
Usage
Mount the component, then Unmount it to trigger the callback.
Empty Slot
Activity Log
No activity yet...
Component.tsx
API
Arguments
fn– () => void The callback function to run on unmount.
Returns
This hook returns
void.