react-use-confirm-leave
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-use-confirm-leave

A react hook to show confirmation dialog when user leave or refresh page

NPM JavaScript Style Guide

Install

npm install --save react-use-confirm-leave

Usage

import * as React from 'react';
 
import useConfirmLeave from 'react-use-confirm-leave';
 
const Example = () => {
  const [needConfirm, setNeedConfirm] = useConfirmLeave(false);
 
  return (
    <div>
      <input type='text' onchange={() => setNeedConfirm(true)} />
      <button onClick={() => setNeedConfirm(false)}>Save</button>
    </div>
  );
};

License

MIT © JasonHeylon

Package Sidebar

Install

npm i react-use-confirm-leave

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.1 kB

Total Files

11

Last publish

Collaborators

  • jasonheylon