How can I use an array of routes for react-router-dom with components with the same props, without rendering the props to every routes seperatley?
const App = () => {
const list = [
{
path: `home`,
element: <Home />
},
{
path: `section`,
element: <Section />
},
];
return (
<BrowserRouter>
<Routes>
{list.map(list => <Route element={list.element ...{ myProp={test} } } path={list.path} )}
<Routes>
</BrowserRouter>
)
}
I'm sure there's a way to render these props inside my map (if I have the list in another file, for example).
Thanks!