GuobaGuoba Utils

useUnmount

@guoba-ai/hook / useUnmount

Function: useUnmount()

function useUnmount(fn): void;

Defined in: useUnmount.ts:15

Run a callback when the component unmounts. The latest callback reference is always used, avoiding stale closure issues.

Parameters

fn

() => void

The callback to run on unmount

Returns

void

Example

useUnmount(() => {
  console.log('Component unmounted!')
})

On this page