@smooks/use-before-leave

1.0.0 • Public • Published

@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

Argument Type Description Required
onBeforeLeave function Function to be called when the mouse leaves the document yes

Readme

Keywords

Package Sidebar

Install

npm i @smooks/use-before-leave

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2 kB

Total Files

4

Last publish

Collaborators

  • 0724ksm