I use ReactRouter v4 with HashRouter to build spa which embeded to the existing page, so i lay on hash routring to switch my views. I don't use global state management like Redux or flux. I suppose to use react as a slim front end. All i need is to send request to the backend everytime when some action occured, and then show appropriate component with data. And offcourse i tried to use RR
history.push(path, state)
and got this error 'Warning: You cannot PUSH the same path using hash history'.
Then i was seeking around the internet for solution and found this comment, @matthewrobb suggested to use BrowserRouter with hash sign at the end and push store. This solution is working, but it adds leading slash at the location like this 'site.com/subpage#/intro-view'.
Luckily i found better solution for my case ๐
In documentation for history
navigation wrote next 'Note: Location state is only supported in createBrowserHistory and createMemoryHistory.'. But if use location object to PUSH and REPLACE this warning do not appear and you can access state in nested components ๐
So instead of invoking
history.push(path, state)
try to use
history.push({pathname: path, state: state})