Show custom prompt/modal on window/tab closed

any ideas how to deal with this part of recruitment task?

"The game saves when the tab/window is closed and a prompt appears to inform the player about this."

beforeunload event is not working well. It only shows the default message.

class App extends React.Component {
  onUnload = e => { 
    e.preventDefault();
    e.returnValue = '';
 }  

 componentDidMount() {
    window.addEventListener("beforeunload", this.onUnload);
 }

 componentWillUnmount() {
     window.removeEventListener("beforeunload", this.onUnload);
 }



  render(){
    return (<div>App</div>)
  }

}

export default App;

4 thoughts on “Show custom prompt/modal on window/tab closed”

  1. [url=https://levitraoffer.com/]levitra professional pills[/url] [url=https://doctorhims.com/]viagra without a doctor prescription[/url] [url=https://otcmailmeds.com/]buy prescription drugs online without[/url] http://allergyd.com cetirizine hydrochloride 10mg cost

    Reply

Leave a Comment