@jacob-hooks/use-before-leave
Version:
React Hook to execute a function when the mouse leaves the page. Useful to show a popup or for analytics.
33 lines (21 loc) • 858 B
Markdown
React Hook to execute a function when the mouse leaves the page. Useful to show a popup or for analytics.
`yarn add @jacob-hooks/use-before-leave`
`npm i @jacob-hooks/use-before-leave`
```js
import React from "react";
import useBeforeLeave from "@jacob-hooks/use-before-leave";
function App() {
const beforeLeave = () => console.log("User is leaving...");
useBeforeLeave(beforeLeave);
return <h1>Hello Nooks</h1>;
}
```
| Argument | Type | Description | Required |
| ----------- | ------ | ------------------------------------------------------------------------ | -------- |
| beforeLeave | string | When the mouse leaves the page. Useful to show a popup or for analytics. | yes |