docs(start): explain that layout routes must render <Outlet>#7852
docs(start): explain that layout routes must render <Outlet>#7852deeferentleeg wants to merge 1 commit into
Conversation
The getting-started routing guide lists posts.tsx as a "Layout" route and shows the <Root><Posts><Post/></Posts></Root> component tree, but never connects the layout-route concept to the <Outlet/> component: the auto- generated placeholder for posts.tsx does not include <Outlet/>, so child routes never render and navigating to /posts/123 shows only the layout. Add a note after the Creating File Routes table (with a runnable example) and a line under Nested Routing explaining that the layout component must render <Outlet/> for child routes to appear. Closes TanStack#5351
📝 WalkthroughWalkthroughThe React routing guide now explains that ChangesNested routing guide
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/start/framework/react/guide/routing.md`:
- Line 175: Update both Outlet documentation links in
docs/start/framework/react/guide/routing.md at lines 175-175 and 207-208 to use
the existing “The Outlet Component” section anchor instead of `#defining-routes`,
preserving the relative documentation-link convention at the sibling site.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: da2d612a-3079-43fb-9e19-8fa454c8c6b6
📒 Files selected for processing (1)
docs/start/framework/react/guide/routing.md
| </Root> | ||
| ``` | ||
|
|
||
| For this tree to render, the `posts.tsx` layout route's component must render an [`<Outlet />`](#defining-routes) — that's where the matching child route (`<Post />`) is displayed. Without `<Outlet />`, only the `<Posts>` component renders and the child route will not appear. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fix both links to the Outlet documentation. Both additions use #defining-routes, which points to the “Defining Routes” section rather than the existing “The Outlet Component” section.
docs/start/framework/react/guide/routing.md#L175-L175: replace the anchor with the correct Outlet-section link.docs/start/framework/react/guide/routing.md#L207-L208: replace the repeated incorrect anchor and follow the relative documentation-link convention.
📍 Affects 1 file
docs/start/framework/react/guide/routing.md#L175-L175(this comment)docs/start/framework/react/guide/routing.md#L207-L208
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/start/framework/react/guide/routing.md` at line 175, Update both Outlet
documentation links in docs/start/framework/react/guide/routing.md at lines
175-175 and 207-208 to use the existing “The Outlet Component” section anchor
instead of `#defining-routes`, preserving the relative documentation-link
convention at the sibling site.
Source: Coding guidelines
Summary
Closes #5351 — new users following the "build from scratch" getting-started flow get stuck because the guide never connects the layout route concept to the
<Outlet />component.The "Creating File Routes" table lists
posts.tsxas a "Layout" route, and the "Nested Routing" section shows the component tree<Root><Posts><Post /></Posts></Root>— but the route generator creates a placeholder component forposts.tsxthat does not include<Outlet />. So when a user follows the guide and navigates to/posts/123, only theposts.tsxcomponent renders and the child route never appears. The<Outlet />component is documented elsewhere in the same guide but isn't bridged to the layout-route concept in the flow new users actually follow.The fix
Two small additions to
docs/start/framework/react/guide/routing.md:> [!NOTE]callout after the "Creating File Routes" table explaining that a layout route's component must render<Outlet />, with a runnableposts.tsxexample.posts.tsxlayout component must render<Outlet />for<Post />to display.Both link to the existing
#defining-routesanchor where<Outlet />is shown.Note
I see there's a draft PR (#7831) touching this area — happy to coordinate or withdraw if that one progresses; this PR is an independent, self-contained docs addition.
AI usage
An AI assistant was used to help locate the relevant code and draft this change. I have reviewed and understand every line of the diff, and I am the sole author of this contribution.
Closes #5351
Summary by CodeRabbit
<Outlet />for child routes to appear.<Outlet />in a layout route.