use-refresh-lock
useRefreshLock - Ensure that user allow the browser to refresh
Installation
yarn add use-refresh-lock
Usage
Create a simple refresh lock
// create a lockconst release = // now when you refresh the browser, the browse will prompt an// 'Change you made may not be save.' prompt (aka Chrome) // release the lock, just call the `release` method returned by `useRefreshLock`
Aditionally, you could provide a callback to useRefreshLock
. Recommended to use only to call navigator.sendBeacon
only.
See: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
const release =
License
License under MIT