For what I understand now, if we pass an Outlet
with context, the props after the context could be passed into child, and outlet act as a template that pass those props into any child the router may render.
My question is, what if we just set <Outlet />
without context? If it doesn't pass any props, is there any reason why we particularly want to use <Outlet />
alone?
Code may look like this
index.js
root.render(
<BrowserRouter>
<Routes>
<Route path="/" element={<App />}>
<Route path="checkout" element={<Checkout />} />
</Route>
</Routes>
</BrowserRouter>
);
App.js
function App() {
return (
<>
<Reset />
<GlobalStyle />
<Header cartItems={cartItems} />
<Outlet />
</>
)
}