How do I 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;