/
7.3/4-nested_routes

7.3/4-nested_routes

We currently have a reusable component called <Calculator> that we can drop on any other component. It would be great if we could get React to render it as needed based on URL patterns. We can use the react-router nested routes.

App.jsx

Notice on line 29 that there is no oblique in front of sales

SalesHistory.jsx

No need to inject the <Calculator> anymore

Calculator.jsx

You need to add an <Outlet>

An <Outlet> sets a component up as a standard layout into which other components can be injected - it tells the react-router where in the parent the child component should be rendered

 

Related content