Nested routes in / don't get rendered #8685
-
Hi I need help migrating to v6, basically our top level component So I started porting code but noticed that exact is no longer an acceptable prop and the docs tell us to use a trailing const route = useRoutes([
{
element: <App />,
path: '/*',
children: [
{
element: <Copy />,
path: 'copy',
children: []
}
]
}
]) Still nothing! the const route = useRoutes([
{
element: <App />,
path: '/*',
children: [
{
element: <Copy />,
path: '/copy',
children: []
}
]
}
]) and I get this error
Which doesn't make much sense because it technically has the combined paths of all its parent routes since parent is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Would this do what you want? import { useRoutes, Outlet } from 'react-router-dom';
const Example = () => {
const element = useRoutes([
{
element: <App />,
children: [
{
index: true,
element: <Home />,
},
{
path: '/copy',
element: <Copy />,
},
],
},
]);
return element;
};
const App = () => (
<div>
<p>As a "layout" route, "children" routes are rendered in the <code><Outlet></code></p>
<Outlet />
</div>
);
const Home = () => <div>This is the "home" route.</div>;
const Copy = () => <div>This is the "copy" route.</div>; Changes from your question example
|
Beta Was this translation helpful? Give feedback.
Would this do what you want?
Changes from your question example
p…