Prevent page unloading from the user's action
$ npm install prevent-unloadimport preventUnload, {cancel} from 'prevent-unload';
const handler = preventUnload();
cancel(handler);messageString (optional) - Message to display on confirm popup. Default is platform specified.
Apply page unloading prevention. If user attempt to close current web page after calling the method, then browser blocks page unloading and shows up popup with specified message.
This method returns reference of handler, which can be used for cancel the behavior.
handlerFunction - Handler reference to cancel event.
Cancel page unloading prevention.