1.0.5 • Published 3 years ago

@gitgw/use-before-leave v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@gitgw/use-before-leave

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

Installation

npm

npm i @gitgw/use-before-leave

yarn

yarn add @gitgw/use-before-leave

Usage

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

function App() {

  const onBeforeLeave = ()=>{
    console.log("onBeforeLeave");
  }

  useBeforeLeave(onBeforeLeave);

  return (
    <div className="App"></div>
  );
}

Arguments

ArgumentTypeDescriptionRequired
onBeforeLeaveFunctionFunction to be called when the mouse leaves the documentyes