Part 15 / Topic 1 of 9
<Routes>, <Route>, and <Link>
examples/01_basic_routes_and_links.jsx's AppShell maps two paths to two components, and links between them:
// examples/01_basic_routes_and_links.jsx
export function AppShell() {
return (
<div>
<nav>
<Link to="/">Home</Link>
<Link to="/orders">Orders</Link>
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/orders" element={<Orders />} />
</Routes>
</div>
);
}
<Routes> looks at the current URL and renders the one <Route> whose path matches, nothing else. <Link to="/orders"> changes that URL on click without asking the browser to reload the page - the whole point of client-side routing: one page load, many URLs. AppShell itself renders no <BrowserRouter> - a real app renders exactly one, once, in main.jsx, around everything; this file exports just the routed part so a test can supply its own router instead (examples/01_basic_routes_and_links.test.jsx wraps it in a MemoryRouter, Section 8 explains why that one specifically). Rendering at / really shows "Swiggy Lite"; clicking the Orders link really swaps it for "Your orders," with nothing reloaded and no Orders-shaped prop anywhere on AppShell's own signature.
Done here? The practice set for Part 15 — including the solutions — is on the part page.