@gitgw/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 (25 loc) • 700 B
Markdown
React Hook to execute a function when the mouse leaves the page. Useful to show a popup or for analytics.
```npm i @gitgw/use-before-leave```
```yarn add @gitgw/use-before-leave```
```javascript
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>
);
}
```
Argument|Type|Description|Required|
|-|-|-|-|
|onBeforeLeave|Function|Function to be called when the mouse leaves the document|yes