@customhooks/use-before-leave
v1.0.1
Published
React Hook to execute a function when the mouse leaves the page
Downloads
2
Maintainers
Readme
@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>;
}