Clicking a React Router Link changes the URL but the new page stays blank
The URL changes to /dashboard/settings but the page still shows the old contentShort answer
The URL change proves the Link works and the router matched a route. What is missing is a place to draw the match. A nested route renders only where its parent puts an Outlet, and an index route cannot have children. Check those two first, then that every Route sits inside Routes.
Fix it fast
1Find out which cause you have
Print the router's current location inside the layout that should show the child. If the pathname changes while nothing renders below it, the route matched and the problem is where it is drawn.
import { useLocation } from 'react-router'; function Dashboard() { const location = useLocation(); console.log(location.pathname); return <h1>Dashboard</h1>; }2Match what you see, then jump to its fix
- 1
Parent content renders, the child component is missing, the console is cleanThe parent route has no OutletFix - 2
A Route with the index prop contains child Route elementsThe child route is nested inside an index routeFix - 3
Route elements are written directly inside a component or Fragment, with no Routes element around themA Route is not rendered inside RoutesFix
- 1
What does the error look like?
The URL changes to /dashboard/settings but the page still shows the old contentThe parent layout renders, the child is missingNo error in the console
Cause 1 of 3
The parent route has no Outlet
1Check
React Router's docs say child routes render through the Outlet in the parent route, and that Outlet renders the matching child route or nothing. A parent element without it has nowhere to show the child.
grep -rLn "<Outlet" src/layouts src/pages2Fix
Render an Outlet in the parent's element at the place the child should appear.
import { Outlet } from 'react-router';
export default function Dashboard() {
return (
<div>
<h1>Dashboard</h1>
<Outlet />
</div>
);
}3Verify
Click the Link again. The child appears under the heading.
npm run devConfirmed by reactrouter.com
Cause 2 of 3
The child route is nested inside an index route
1Check
The routing guide states that index routes cannot have children. Children placed inside one are never rendered.
grep -rnE "<Route index" src2Fix
Move the children to a layout route: a Route without a path adds nesting without adding a URL segment.
<Route path="dashboard" element={<Dashboard />}>
<Route index element={<Home />} />
<Route path="settings" element={<Settings />} />
</Route>3Verify
Visit /dashboard/settings. The Settings component renders inside Dashboard's Outlet.
console.log(window.location.pathname); // /dashboard/settingsConfirmed by reactrouter.com
Cause 3 of 3
A Route is not rendered inside Routes
1Check
The Route reference states that a Route must be rendered within a Routes element. Check the component that holds your Route elements.
grep -rnE "<Routes|<Route " src2Fix
Wrap the Route elements in Routes, inside the BrowserRouter.
<BrowserRouter>
<Routes>
<Route path="/" element={<App />} />
</Routes>
</BrowserRouter>3Verify
Click the Link. The route's element mounts.
console.log(window.location.pathname);Confirmed by reactrouter.com
How do I stop it coming back?
- Give every parent route element an Outlet as part of writing the layout.
- Use a pathless layout route when you need nesting without a URL segment.
- Add a test that navigates to each nested URL and checks the child text is on screen.
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
Show a 404 page for unknown URLs in React Router
An unknown URL shows the router default error screen instead of your own page
React Router only renders a page when a route matches the URL.
2 causes, each with a fixWeb 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 fix