Skip to content

Instantly share code, notes, and snippets.

@night-fury-rider
Created March 23, 2021 06:56
Show Gist options
  • Save night-fury-rider/926be020f832c1f3069e186c1e17392b to your computer and use it in GitHub Desktop.
Save night-fury-rider/926be020f832c1f3069e186c1e17392b to your computer and use it in GitHub Desktop.
React Router
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