1.0.1 • Published 4 years ago

@customhooks/use-before-leave v1.0.1

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

@customhooks/use-before-leave

React Hook to execute a function when the mouse leaves the page.

Installaction

npm install @customhooks/use-before-leave

or

yarn add @customhooks/use-before-leave

Usage

useBeforeLeave() have a one argument like this :
useBeforeLeave(onBeforeLeave)

onBeforeLeave is must be function.

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

function App() {
    const beforeLeave = () => console.log("Leaving Now");
    useBeforeLeave(beforeLeave);

    return <h1>Hello World!</h1>;
}