A layout component should render an Outlet
for nested Route
components to be rendered into. This is different from wrapper components that consume and render the children
prop.
See Layout Routes and Outlet for more details.
import { Outlet } from 'react-router-dom';
const Layout = () => {
return (
<div>
<Outlet /> // <-- nested routes rendered here!
</div>
)
};
For comparison, wrapper components are used to wrap a child component in the element
prop. Example:
<Routes>
<Route
path="/"
element={(
<Layout>
<MainLanding />
</Layout>
)}
/>
<Route
path="/store"
element={(
<Layout>
<StoreLanding />
</Layout>
)}
/>
</Routes>