Suppose a user comes to some page of my website. Here user have clicked on some shared link which opens a new tab in users' browser.
Now if user clicks on back button, then user should land on home page instead of going back to blank page of browser.
I tried using history.listen method provided by react-router. But I am not able to redirect user to home page.
here is the code snippet
componentDidMount(){
this.props.history.listen((location, action) => {
if (action === 'POP') {
this.props.history.push('/homepage');
}
}