1.0.0 • Published 9 months ago

@smooks/use-before-leave v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@smooks/use-before-leave

React Hook to execute a function when the mouse leaves the page. Useful to show a popup or for analytics.

Installation

yarn

yarn add @smooks/use-before-leave

npm

npm i @smooks/use-before-leave

Usage

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

    function App() {
        const beforeLeave = () => console.log("User is leaving...");
        useBeforeLeave(beforeLeave);
        return <h1>Hello Nooks</h1>;
    }

Argument

ArgumentTypeDescriptionRequired
onBeforeLeavefunctionFunction to be called when the mouse leaves the documentyes
1.0.0

9 months ago