OK, I'm tired of trying.
The onEnter method onEnter not work. Any idea why?
// Authentication "before" filter function requireAuth(nextState, replace){ console.log("called"); // => Is not triggered at all if (!isLoggedIn()) { replace({ pathname: '/front' }) } } // Render the app render( <Provider store={store}> <Router history={history}> <App> <Switch> <Route path="/front" component={Front} /> <Route path="/home" component={Home} onEnter={requireAuth} /> <Route exact path="/" component={Home} onEnter={requireAuth} /> <Route path="*" component={NoMatch} /> </Switch> </App> </Router> </Provider>, document.getElementById("lf-app")
Edit:
The method is executed when I call onEnter={requireAuth()} , but obviously this is not the goal, and I will not get the necessary parameters either.
reactjs react-router react-router-v4
Trace Mar 13 '17 at 16:23 2017-03-13 16:23
source share