usePageLeave

March 27, 2019 ยท View on GitHub

React sensor hook that fires a callback when mouse leaves the page.

Usage

import {usePageLeave} from 'react-use';

const Demo = () => {
  usePageLeave(() => console.log('Page left...'));

  return null;
};