I am trying to control my application navigation from my state. Here is my use case:
Given the user is on the Login page When the application state changes to isLoggedIn Then the application should navigate to the Dashboard page
Here is my current implementation that works:
if (browserHistory.getCurrentLocation().pathname === '/login' && store.isLoggedIn) { browserHistory.push('/dashboard'); }
Unfortunately, going through documents and problems with reactor routers, I understand that browserHistory.getCurrentLocation() not an official API and should not be used. Is there a recommended way to do this?
PS This code works outside of the React component, so I cannot use this.props.location.pathname
source share