use-page-leave

Call function when mouse leaves the page
Import

Usage

use-page-leave calls given function when mouse leaves the page:

Mouse left the page 0 times
import { useState } from 'react';
import { usePageLeave } from '@mantine/hooks';
import { Text } from '@mantine/core';
function Demo() {
const [leftsCount, setLeftsCount] = useState(0);
usePageLeave(() => setLeftsCount((p) => p + 1));
return <>Mouse left the page {leftsCount} times</>;
}

Definition

function usePageLeave(onPageLeave: () => void): void;
Build fully functional accessible web applications faster than ever
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback