JSFiddle - React, Tailwind, and code Playground
by Bruno Krebs
HTML
<h1>
don't leave please
</h1>
JavaScript
window.onbeforeunload = function(event) {
// do some stuff here, like reloading your current state
//this would work only if the user chooses not to leave the page
return 'why would you do that???';
}