Basic react-router 4 setup for login and protected routes.
Assuming there is a UserStore
that can perform the actual operations. It also provides a user
prop to pages when the user is logged in.
Omitting any insiginificant import statements. This is not copy-pastable code, but still real-world code. (Omitted some project/ui-specific stuff)
Renders the App
, but wrapped in a Router
. That way we can use Route
and Switch
components anywhere in our app tree.