Hi all. I have a parent component that defines a /overview route and renders a child component on this route.
The child component has its own navigation and I want it to have the following routes:
/overview -> Overview
/overview/:id -> Details
/overview/:id/edit -> Edit
/overview/add -> Add
And this is not working with my current implementation (pseudo code) because index routes cannot have children:
export const OverviewModule = () => {
return (
<Routes>
<Route element={<Outlet />}>
<Route
index
element={
// This is not allowed to have an index route with nested routes. How to achieve this?
<ResourceOverview />
}
>
<Route path=":id" element={<ResourceDetails />}>
<Route path="edit" element={<ResourceEdit />} />
</Route>
<Route path="add" element={<ResourceAdd />} />
</Route>
<Route
path="*"
element={
// How to navigate back to the index here?
<Navigate to="." />
}
/>
</Route>
</Routes>
);
};
export const App = () => {
return (
<Routes>
<Route index element={<Navigate to="overview" />} />
<Route path="overview">
<Route index element={<OverviewModule />} />
<Route path="import" element={<ImportPage />} />
</Route>
</Routes>
);
};
Any help would be appreciated 🙂