I'm doing user login and logout and after login or logout i am just changing pathname to homepage using this.props.history.push({pathname: '/', state: { url: this.props.location.pathname }});. Now when i redirect to that page the data is not updating, i have refresh the page to update the data. I am calling below code to update the data.
componentDidMount(){
let data = AuthService.fetchUserObj();
console.log(data)
this.setState({user: data})
}
Please assist me how to automatically update user data to state once pathname changed after login.