I'm new to React and hope someone can shed some light on why this is happening and how to debug it.
I have defined the following routes:
export default (withHistory, onUpdate) => { const history = withHistory? (Modernizr.history ? new BrowserHistory : new HashHistory) : null; return ( <Router history={history}> <Route path='/login' component={Login} /> <Route path='/' component={Home} onEnter={requireAuth} /> </Router> ); };
requireAuth should check if the user is registered and redirect him to the login page if not:
function requireAuth(nextState, transition) { transition.to("/login"); }
If I leave the call to transtion.to and go to the root URL, I just see a message saying "Can not Get /" without error messages in the debugger. Finding a breakpoint on this line does nothing.
Which is especially strange if I replaced transition.to(...) with a debugger; statement debugger; , then the method is called, and routing works fine.
I should have some misunderstanding, some ideas about what it is?
Edit: I have to add that switching to host:port/login works fine, so I know that the login route works.
javascript url-routing reactjs
shieldstroy
source share