Nested routes with react router v4
|Added at||2017-01-04 23:01|
I am currently struggling with nesting routes using react router v4.
The closest example was the route config in the React-Router v4 Documentation.
I want to split my app in 2 different parts.
A frontend and an admin area.
I was thinking about something like this:
The frontend has a different layout and style than the admin area. So within the frontpage the route home, about and so one should be the child routes.
/home should be rendered into the Frontpage component and /admin/home should be rendered within the Backend component.
I tried some variations but I always ended in not hitting /home or /admin/home.
With the solution from @azium I managed to get it work with the following code:
I added a redirect to frontend when someone is hitting the root path so I don't have to wrap my components with a frontpage component all the time.