Child routes in React Router do not render inside the parent page
The parent layout renders but the child page is emptyShort answer
A child route does not appear by itself. The parent route's component must render an Outlet, which is where React Router places the matching child. Also check that child paths are relative (no leading slash), and that the parent has an index route for the bare parent URL.
Fix it fast
1Find out which cause you have
Open the component used as the parent route's element and search it for Outlet. If it is not there, the first cause is yours.
grep -rn "Outlet" src/2Match what you see, then jump to its fix
- 1
The parent page shows, the URL is the child's URL, the child area is blankThe parent component does not render an OutletFix - 2
The child only renders at a doubled URL such as /dashboard/dashboard/settingsThe child path repeats the parent or starts with a slashFix - 3
/dashboard shows the layout with an empty content areaNothing is defined for the bare parent URLFix
- 1
What does the error look like?
The parent layout renders but the child page is emptyThe URL changes to /dashboard/settings and nothing else changes on screen
Cause 1 of 3
The parent component does not render an Outlet
1Check
The docs say child routes are rendered through the Outlet in the parent route. A parent element without one has nowhere to put the child.
grep -n "Outlet" src/pages/Dashboard.jsx2Fix
Import Outlet and place it where the child should appear.
import { Outlet } from "react-router-dom";
export default function Dashboard() {
return (
<div>
<h1>Dashboard</h1>
<Outlet />
</div>
);
}3Verify
Open /dashboard/settings. The heading and the settings page both show.
npm run devConfirmed by reactrouter.com
Cause 2 of 3
The child path repeats the parent or starts with a slash
1Check
The parent's path is automatically included in the child, so a child written as dashboard/settings under a dashboard parent doubles the segment.
grep -rn "<Route" src/2Fix
Write the child path relative to its parent.
<Routes>
<Route path="dashboard" element={<Dashboard />}>
<Route index element={<Home />} />
<Route path="settings" element={<Settings />} />
</Route>
</Routes>3Verify
Both /dashboard and /dashboard/settings match a route.
npm run devConfirmed by reactrouter.com
Cause 3 of 3
Nothing is defined for the bare parent URL
1Check
An index route renders into its parent's Outlet at the parent's URL. Without one, the outlet is empty there.
grep -n "index" src/App.jsx2Fix
Add an index route as the default child. Index routes cannot have children of their own; use a layout route for that.
<Route path="dashboard" element={<Dashboard />}>
<Route index element={<Home />} />
</Route>3Verify
Open /dashboard and confirm that Home renders inside the layout.
npm run devConfirmed by reactrouter.com
How do I stop it coming back?
- Give each layout component an Outlet the moment you create it.
- Use relative child paths and an index route in every parent.
- Keep the route tree in one file so the nesting is visible.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
Module not found for antd/dist/antd.less after upgrading to Ant Design 5
Module not found: Error: Can't resolve 'antd/dist/antd.less'
Ant Design 5 dropped Less and the bundled CSS file for CSS-in-JS, so antd/dist/antd.less no longer exists.
3 causes, each with a fixWeb apps
Astro Code component fails inside a React component
Astro components cannot be rendered directly via function call
Astro components such as Code only exist on the server and render static HTML.
2 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
How to catch and handle a 422 from Axios in a Redux thunk
action.error.message is 'Rejected' and action.payload is undefined
A 422 means the server read the request but cannot process its content, so repeating it unchanged fails again.
4 causes, each with a fixWeb apps
axios gets 429 Too Many Requests from a React app
429 (Too Many Requests)
A 429 comes from the server or an API gateway, not from axios: your client sent too many requests in a window.
4 causes, each with a fixWeb apps
Axios request is not cancelled when a React component unmounts
A cancelled request is logged as an error in the catch block
Axios cancels a request when you pass it an AbortSignal and later call abort() on its controller.
4 causes, each with a fix