using "response-router": "^ 3.0.2",
When I reload the page, I need it to go to the default view that it is currently doing. However, the actual route that is in the story still matches the one from which I made the update. So the component is remounted when it should not be.
routing history
export const browserHistory = useRouterHistory(useBeforeUnload(createHistory))()
routes
<Router history={browserHistory}> <Route path='/' name='Auth' component={Auth}> <IndexRoute component={Dashboard} onEnter={(nextState, replace) => replace('/login')} /> <Route path='dashboard' name='Dashboard' component={Dashboard} /> <Route path='resources' name='Resources' component={Resources} /> <Route path='users' name='Users' component={UsersContainer} /> <Route path='user/:params' name='User' component={UserContainer} /> </Route> <Route path='/' name='NoAuth' component={NoAuth}> <Route path='login' name='Login Page' component={Login} /> </Route> </Router>
This is how I check if the user still has a valid session token and how I am redirected to the control panel. Not sure if I am doing this in the best way.
const _checkAuth = () => { if (profile) { const res = JSON.parse(profile) store.dispatch({ type: types.LOGIN_IDENTITY_SUCCESS, res }) console.log(browserHistory.getCurrentLocation().pathname) router.replace('/dashboard') } } _checkAuth()
source share