fn
usePageLeave
v0.0.15testeddemoReactive flag indicating whether the mouse has left the page.
Examples
ts
const hasLeft = usePageLeave();ts
usePageLeave({
onChange: (isLeft) => {
if (isLeft) showExitIntentModal();
},
});Demo
Loading demo…
Signature
ts
export function usePageLeave(options: UsePageLeaveOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UsePageLeaveOptions | Options (custom `window`, `onChange` callback) |
Returns
UsePageLeaveReturnWhether the pointer has left the page