Last active
February 19, 2020 19:32
-
-
Save ryanflorence/e9cf839313e8af9d73ace5f4f3b64a2d to your computer and use it in GitHub Desktop.
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
import React from "react" | |
import { Link, useRoutes, Outlet } from "react-router-dom" | |
function App() { | |
const el = useRoutes([ | |
{ path: "/", element: <div>index</div> }, | |
{ | |
path: ":courseId", | |
element: ( | |
<div> | |
Course ID | |
<hr /> | |
<Outlet /> | |
</div> | |
), | |
// if you uncomment the children, then suddenly this match has | |
// a bigger priority than the static "/home" | |
// children: [ | |
// { path: '/', element: <div>Course Index</div> }, | |
// { path: ':chapter', element: <div>Chapter</div> } | |
// ] | |
}, | |
{ | |
path: "home", | |
element: <div>Home</div> | |
} | |
]) | |
return ( | |
<div> | |
<Link to="/">Index</Link> <Link to="/home">Home</Link>{" "} | |
<Link to="/c/some-course">Some Course</Link> | |
<hr /> | |
{el} | |
</div> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment