reactjs - react-router auto-login in the onEnter hook -
in react-router examples onenter hook, hook synchronous. in issues it's recommended keep way. what's idiomatic way log in while inside hook? user-story: client has localstore token client navigates directly example.com/mustbeloggedin before going page, i'd check if have token, if do, attempt gain authorization. if authorized, continue onto route should use hoc instead of onenter ? i have working, know it's not recommended, , seems brittle, example using immutable store causes same issues issue: https://github.com/rackt/react-router/issues/2365 there number of ways solve challenge, agree recommendation calls in onenter should synchronous. here 2 ways solve challenge. option 1: don't validate token on page load it arguably case browser should not validate existing token @ all. is, browser should assume token valid , try load route defined. on api call failure response server (where actual authentication , authorization occurring), app ...