Created
March 23, 2021 06:56
-
-
Save night-fury-rider/926be020f832c1f3069e186c1e17392b to your computer and use it in GitHub Desktop.
React Router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = [ | |
{ | |
path: "/sandwiches", | |
component: Sandwiches | |
}, | |
{ | |
path: "/tacos", | |
component: Tacos, | |
routes: [ | |
{ | |
path: "/tacos/bus", | |
component: Bus | |
}, | |
{ | |
path: "/tacos/cart", | |
component: Cart | |
} | |
] | |
} | |
]; | |
export default function UvApp() { | |
return ( | |
<Router> | |
<div> | |
<Link to="/tacos">Tacos</Link> | |
<Link to="/sandwiches">Sandwiches</Link> | |
<Switch> | |
{routes.map((route, i) => ( | |
<RouteWithSubRoutes key={i} {...route} /> | |
))} | |
</Switch> | |
</div> | |
</Router> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment