1.0.2 • Published 5 years ago

@nooks/use-before-leave v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@nooks/use-before-leave

React Hook to execute a function when the mouse leaves the page. Useful to show a popup or for analytics.

Installation

yarn

yarn add @nooks/use-before-leave

npm

npm i @nooks/use-before-leave

Usage

import React from "react";
import useBeforeLeave from "@nooks/use-before-leave";

function App() {
  const beforeLeave = () => console.log("User is leaving...");
  useBeforeLeave(beforeLeave);
  return <h1>Hello Nooks</h1>;
}

Arguments

ArgumentTypeDescriptionRequired
onBeforeLeavefunctionFunction to be called when the mouse leaves the documentyes