Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Last active February 19, 2020 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanflorence/e9cf839313e8af9d73ace5f4f3b64a2d to your computer and use it in GitHub Desktop.
Save ryanflorence/e9cf839313e8af9d73ace5f4f3b64a2d to your computer and use it in GitHub Desktop.
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