<Router>
<Route path={["/home", "/users", "/widgets"]} component={Home} />
</Router>
<Router>
<Route path={["/home", "/users", "/widgets"]} component={Home} />
</Router>
import { Outlet } from 'react-router-dom';
const AppLayout = () => (
<>
<NavBar />
<SideBar />
<main className={styles["main--container"]}>
<div className={styles["main--content"]}>
<Outlet /> // <-- nested routes rendered here
</div>
</main>
</>
);
const App = () => {
return (
<>
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route element={<AppLayout />} >
<Route path="/" element={<Dashboard />} /> // <-- nested routes
</Route>
</Routes>
</>
);
};
//use multiple components in one Route:
<Route path='/path' render={props =>
<div>
<FirstChild />
<SecondChild />
</div>
} />
<Routes>
<Route
path="/"
element={[
<Header key={1} />,
<LandingSection key={2} />,
<CardList key={3} /> ]}>
</Route>
</Routes>
<Router>
{["/home", "/users", "/widgets"].map((path, index) =>
<Route path={path} component={Home} key={index} />
)}
</Router>
import React from "react";
import {
BrowserRouter as Router,
useRoutes,
} from "react-router-dom";
const App = () => useRoutes([
{ path: "/home", element: <Home /> },
{ path: "/users", element: <Home /> },
{ path: "/widgets", element: <Home /> }
]);
const AppWrapper = () => (
<Router>
<App />
</Router>
);