I am using React. I want to warn the user when the user clicks on the back button.
What I had done was
handleWindowClose = (ev) => { ev.preventD
Try this code:
componentDidMount() { window.addEventListener("popstate", this.onBackButtonEvent) } componentWillUnmount() { window.removeEventListener("popstate", this.onBackButtonEvent) } onBackButtonEvent = () => { window.history.forward() }