onEnter not called in React-Router
onEnter no longer exists on react-router-4. You should use <Route render={ … } /> to get your desired functionality. I believe Redirect example has your specific scenario. I modified it below to match yours.
onEnter no longer exists on react-router-4. You should use <Route render={ … } /> to get your desired functionality. I believe Redirect example has your specific scenario. I modified it below to match yours.
You’re going to want to use the Redirect component. There’s a few different approaches to this problem. Here’s one I like, have a PrivateRoute component that takes in an authed prop and then renders based on that props. Now your Routes can look something like this If you’re still confused, I wrote this post that may help – Protected routes and … Read more