\'react-router-dom\' has refresh function here, but I don\'t know how to call this method, also their well formatted document doesn\'t bother to explain this.
windo
Only this worked for me:
reloadOrNavigate = () => {
const { history, location } = this.props;
if (location.pathname === '/dashboard') {
history.replace(`/reload`);
setTimeout(() => {
history.replace(`/dashboard`);
});
} else {
history.push('/dashboard');
}
};
The answer is similar to the previous one but I needed to add setTimeout function in order to make it work. In my case, I had to refresh the current URL by clicking the logo if I'm on the /dashboard page. First, it goes to extra route /reload (the name is up to you) and then immediately returns. The page becomes white for less than a second and appears with reloaded data. No reloading in browser occurs, it is still SPA which is good.