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.returnValue = '';

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

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

    return (<div>App</div>)


export default App;

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

  1. [url=]levitra professional pills[/url] [url=]viagra without a doctor prescription[/url] [url=]buy prescription drugs online without[/url] cetirizine hydrochloride 10mg cost

  2. Show custom prompt/modal on window/tab closed – JavaScript Help where to buy ivermectin for humans [url=]ivermectina para humanos[/url] ivermectin 6 mg