react-use-confirm-leave
v1.0.0
Published
A react hook to show confirmation dialog when user leave or refresh page
Downloads
4
Maintainers
Readme
react-use-confirm-leave
A react hook to show confirmation dialog when user leave or refresh page
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