@gitgw/use-prevent-leave

1.0.1 • Public • Published

@gitgw/use-prevent-leave

React Hook to prompt the user for confirmation before leaving the page.

Installation

npm

npm i @gitgw/use-prevent-leave

yarn

yarn add @gitgw/use-prevent-leave

Usage

import React from "react";
import usePreventLeave from "@gitgw/use-prevent-leave";

function App() {
  const { enablePrevent, disablePrevent } = usePreventLeave();

  return (
    <div className="App">
      <button onClick={enablePrevent}>enablePrevent</button>;
      <button onClick={disablePrevent}>disablePrevent</button>;
    </div>
  );
}

Return

Return value Type Description
enablePrevent Function Function to use enable the leaving prevention
disablePrevent Function Function to use disable the leaving prevention

Package Sidebar

Install

npm i @gitgw/use-prevent-leave

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

2.07 kB

Total Files

4

Last publish

Collaborators

  • githubgw