@gitgw/use-before-leave

1.0.5 • Public • Published

@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

Argument Type Description Required
onBeforeLeave Function Function to be called when the mouse leaves the document yes

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @gitgw/use-before-leave

      Weekly Downloads

      2

      Version

      1.0.5

      License

      MIT

      Unpacked Size

      1.93 kB

      Total Files

      4

      Last publish

      Collaborators

      • githubgw