I've defined nested routes using createBrowserRouter
and I expected that the router would route to my child page. However, it seems to stop at the top-level part of the url. BlogsPage
and SampleBlog
are both React components.
I expected "https://adomain/blogs/sampleblog"
to get routed to SampleBlog
not to BlogsPage
. I thought I could nest as deeply as I liked and that the router would match the longest matching path and invoke that component.
const router = createBrowserRouter([
{
path: "/",
element: <App />,
errorElement: <ErrorPage />,
children: [
{ path: "", element: <HomePage /> },
{ path: "home", element: <HomePage /> },
{
path: "blogs",
element: <BlogsPage /> },
children: [
{ path: "sampleblog", element: <SampleBlog /> },
]
},
]
},
]);