Skip to content

fix(router): warn when Outlet is rendered in fallback components - #8045

Merged
Sheraff merged 1 commit into
mainfrom
fix/outlet-fallback-warning
Aug 12, 2026
Merged

fix(router): warn when Outlet is rendered in fallback components#8045
Sheraff merged 1 commit into
mainfrom
fix/outlet-fallback-warning

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Fixes #8042

Summary

  • warn in development when Outlet is rendered inside pending, error, or not-found components
  • cover React, Solid, and Vue route and router-level fallback rendering paths
  • add framework-specific regression tests and patch changesets for all three router packages

Production bundles

  • React and Vue production bundles are byte-for-byte unchanged
  • Solid production bundle is slightly smaller (3 bytes gzip, 14 bytes raw)
  • emitted production bundles contain no warning or context helper code

Tests

  • CI=1 NX_DAEMON=false pnpm nx affected --target=test:eslint --exclude="examples/**,e2e/**" --outputStyle=stream --skipRemoteCache
  • CI=1 NX_DAEMON=false pnpm nx affected --target=test:types --exclude="examples/**" --outputStyle=stream --skipRemoteCache
  • CI=1 NX_DAEMON=false pnpm nx affected --target=test:unit --exclude="examples/**,e2e/**" --outputStyle=stream --skipRemoteCache

Summary by CodeRabbit

  • Bug Fixes

    • Added development-time warnings when <Outlet /> is rendered inside pending, error, or not-found components across React, Solid, and Vue Router.
    • Preserved existing production rendering behavior.
    • Improved warnings for invalid <Outlet /> usage during loading, error, and not-found states.
  • Tests

    • Added comprehensive coverage for valid and invalid <Outlet /> rendering scenarios across all supported frameworks.

@nx-cloud

nx-cloud Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit d429d9c

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 12m View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 49s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-11 19:51:01 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

4 package(s) bumped directly, 19 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.25 → 1.170.26 Changeset
@tanstack/router-core 1.171.21 → 1.171.22 Changeset
@tanstack/solid-router 1.170.24 → 1.170.25 Changeset
@tanstack/vue-router 1.170.23 → 1.170.24 Changeset
@tanstack/react-start 1.168.42 → 1.168.43 Dependent
@tanstack/react-start-client 1.168.23 → 1.168.24 Dependent
@tanstack/react-start-rsc 0.1.41 → 0.1.42 Dependent
@tanstack/react-start-server 1.167.30 → 1.167.31 Dependent
@tanstack/router-cli 1.167.27 → 1.167.28 Dependent
@tanstack/router-generator 1.167.27 → 1.167.28 Dependent
@tanstack/router-plugin 1.168.29 → 1.168.30 Dependent
@tanstack/router-vite-plugin 1.167.29 → 1.167.30 Dependent
@tanstack/solid-start 1.168.41 → 1.168.42 Dependent
@tanstack/solid-start-client 1.168.23 → 1.168.24 Dependent
@tanstack/solid-start-server 1.167.30 → 1.167.31 Dependent
@tanstack/start-client-core 1.170.21 → 1.170.22 Dependent
@tanstack/start-plugin-core 1.171.33 → 1.171.34 Dependent
@tanstack/start-server-core 1.169.25 → 1.169.26 Dependent
@tanstack/start-static-server-functions 1.167.26 → 1.167.27 Dependent
@tanstack/start-storage-context 1.167.23 → 1.167.24 Dependent
@tanstack/vue-start 1.168.40 → 1.168.41 Dependent
@tanstack/vue-start-client 1.167.26 → 1.167.27 Dependent
@tanstack/vue-start-server 1.167.30 → 1.167.31 Dependent

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

React, Solid, and Vue Router now wrap pending, error, and not-found components with development-only context. Outlet reads that context and warns when rendered inside those components. Tests cover valid route rendering and warning cases.

Changes

Outlet context warning

Layer / File(s) Summary
Non-route component context
packages/*-router/src/nonRouteComponentContext.tsx, .changeset/friendly-outlets-warn.md
Added framework-specific development contexts and helpers for identifying pending, error, and not-found components. Added patch release metadata.
React warning integration
packages/react-router/src/{Match,CatchBoundary,renderRouteNotFound}.tsx, packages/react-router/tests/Outlet.test.tsx
React fallback components now provide context, and Outlet warns when it detects that context. Tests cover route, pending, error, and not-found rendering.
Solid warning integration
packages/solid-router/src/{Match,Matches,CatchBoundary,renderRouteNotFound}.tsx, packages/solid-router/tests/Outlet.test.tsx
Solid fallback components now provide context, and Outlet warns in development. Tests cover route, pending, error, and not-found rendering.
Vue warning integration
packages/vue-router/src/{Match,Matches,CatchBoundary,renderRouteNotFound}.tsx, packages/vue-router/tests/Outlet.test.tsx
Vue fallback components now provide injected context, and Outlet watches it to warn in development. Tests cover route, pending, error, transition, and not-found rendering.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested labels: documentation

Sequence Diagram(s)

sequenceDiagram
  participant Match
  participant nonRouteComponentContext
  participant Outlet
  participant Console
  Match->>nonRouteComponentContext: Provide pending, error, or notFound context
  Outlet->>nonRouteComponentContext: Read component context
  nonRouteComponentContext-->>Outlet: Return component identifier
  Outlet->>Console: Log development warning
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: development warnings when Outlet renders inside fallback components.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/outlet-fallback-warning

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 75116dd7daa3
  • Measured at: 2026-08-11T19:40:10.430Z
  • Baseline source: history:7e93431ae9ff
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
solid-router.minimal 33.23 KiB -3 B (-0.01%) 33.11 KiB 96.49 KiB 30.01 KiB ██▁▁▁▁▁▁▁▁▁▁
solid-router.full 38.06 KiB -5 B (-0.01%) 37.93 KiB 111.13 KiB 34.28 KiB ██▁▁▁▁▁▁▁▁▁▁
solid-start.minimal 46.01 KiB -4 B (-0.01%) 45.88 KiB 137.55 KiB 40.92 KiB ██▁▁▁▁▁▁▁▁▁▁
solid-start.deferred-hydration 49.08 KiB +2 B (+0.00%) 45.95 KiB 145.01 KiB 43.72 KiB ██▁▁▁▁▁▁▁▁▁▁
solid-start.full 51.09 KiB -1 B (-0.00%) 50.96 KiB 152.94 KiB 45.26 KiB ██▁▁▁▁▁▁▁▁▁▁

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@packages/react-router/tests/Outlet.test.tsx`:
- Around line 49-146: Extend the Outlet warning coverage with router-level
fallback cases: configure defaultPendingComponent, defaultErrorComponent, and
defaultNotFoundComponent in createRouter while omitting the corresponding
route-level options. Mirror the existing pending, error, and not-found scenarios
and assert outletWarning uses each fallback component name.

In `@packages/vue-router/src/nonRouteComponentContext.tsx`:
- Around line 35-45: Update the exported renderInNonRouteComponentContext props
parameter to remove any, using unknown or the appropriate Vue raw-props type
accepted by Vue.h while preserving support for optional props. Keep the existing
component rendering and context-provider behavior unchanged.
🪄 Autofix

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 Plus

Run ID: 7ef4b981-d6c6-4420-b089-7b3a836604d8

📥 Commits

Reviewing files that changed from the base of the PR and between 7e93431 and d429d9c.

📒 Files selected for processing (18)
  • .changeset/friendly-outlets-warn.md
  • packages/react-router/src/CatchBoundary.tsx
  • packages/react-router/src/Match.tsx
  • packages/react-router/src/nonRouteComponentContext.tsx
  • packages/react-router/src/renderRouteNotFound.tsx
  • packages/react-router/tests/Outlet.test.tsx
  • packages/solid-router/src/CatchBoundary.tsx
  • packages/solid-router/src/Match.tsx
  • packages/solid-router/src/Matches.tsx
  • packages/solid-router/src/nonRouteComponentContext.tsx
  • packages/solid-router/src/renderRouteNotFound.tsx
  • packages/solid-router/tests/Outlet.test.tsx
  • packages/vue-router/src/CatchBoundary.tsx
  • packages/vue-router/src/Match.tsx
  • packages/vue-router/src/Matches.tsx
  • packages/vue-router/src/nonRouteComponentContext.tsx
  • packages/vue-router/src/renderRouteNotFound.tsx
  • packages/vue-router/tests/Outlet.test.tsx

Comment on lines +49 to +146
test('warns when Outlet is rendered inside a pendingComponent', async () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
const pending = createControlledPromise<void>()
const rootRoute = createRootRoute({ component: Outlet })
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/',
component: () => <span>Index route</span>,
})
const pendingRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/pending',
loader: () => pending,
pendingMs: 0,
pendingComponent: () => (
<>
<span>Pending route</span>
<Outlet />
</>
),
component: () => <span>Resolved route</span>,
})
const router = createRouter({
routeTree: rootRoute.addChildren([indexRoute, pendingRoute]),
history: createMemoryHistory({ initialEntries: ['/'] }),
})

render(<RouterProvider router={router} />)
await screen.findByText('Index route')

const navigation = router.navigate({ to: '/pending' })
expect(await screen.findByText('Pending route')).toBeInTheDocument()
pending.resolve()
await navigation

expect(warn).toHaveBeenCalledWith(outletWarning('pendingComponent'))
})

test('warns when Outlet is rendered inside an errorComponent', async () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
const rootRoute = createRootRoute({ component: Outlet })
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/',
loader: () => {
throw new Error('Loader failed')
},
errorComponent: () => (
<>
<span>Error route</span>
<Outlet />
</>
),
})
const router = createRouter({
routeTree: rootRoute.addChildren([indexRoute]),
history: createMemoryHistory({ initialEntries: ['/'] }),
})

render(<RouterProvider router={router} />)

expect(await screen.findByText('Error route')).toBeInTheDocument()
expect(warn).toHaveBeenCalledWith(outletWarning('errorComponent'))
})

test('warns when Outlet is rendered inside a notFoundComponent', async () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
const rootRoute = createRootRoute({ component: Outlet })
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/',
component: () => <span>Index route</span>,
})
const notFoundRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/not-found',
component: () => {
throw notFound()
},
notFoundComponent: () => (
<>
<span>Not found route</span>
<Outlet />
</>
),
})
const router = createRouter({
routeTree: rootRoute.addChildren([indexRoute, notFoundRoute]),
history: createMemoryHistory({ initialEntries: ['/'] }),
})

render(<RouterProvider router={router} />)
await screen.findByText('Index route')
await router.navigate({ to: '/not-found' })

expect(await screen.findByText('Not found route')).toBeInTheDocument()
expect(warn).toHaveBeenCalledWith(outletWarning('notFoundComponent'))
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add router-level fallback warning tests.

These tests cover only route-level pendingComponent, errorComponent, and notFoundComponent options. Add cases that configure defaultPendingComponent, defaultErrorComponent, and defaultNotFoundComponent on createRouter while the affected route omits its equivalent option.

This is required by the PR objective for router-level fallback coverage.

🤖 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 `@packages/react-router/tests/Outlet.test.tsx` around lines 49 - 146, Extend
the Outlet warning coverage with router-level fallback cases: configure
defaultPendingComponent, defaultErrorComponent, and defaultNotFoundComponent in
createRouter while omitting the corresponding route-level options. Mirror the
existing pending, error, and not-found scenarios and assert outletWarning uses
each fallback component name.

Comment on lines +35 to +45
export function renderInNonRouteComponentContext(
component: Vue.Component,
props: Record<string, any> | undefined,
context: NonRouteComponent,
): Vue.VNode {
return Vue.h(
NonRouteComponentContextProvider!,
{ value: context },
{ default: () => Vue.h(component, props) },
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove any from the exported props contract.

Record<string, any> disables type checking for every prop passed through this helper. Use unknown or a Vue raw-props type that is compatible with Vue.h.

As per coding guidelines, **/*.{ts,tsx} must use “TypeScript strict mode with extensive type safety.”

🤖 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 `@packages/vue-router/src/nonRouteComponentContext.tsx` around lines 35 - 45,
Update the exported renderInNonRouteComponentContext props parameter to remove
any, using unknown or the appropriate Vue raw-props type accepted by Vue.h while
preserving support for optional props. Keep the existing component rendering and
context-provider behavior unchanged.

Source: Coding guidelines

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8045

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8045

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8045

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8045

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8045

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8045

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8045

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8045

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8045

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8045

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8045

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8045

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8045

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8045

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8045

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8045

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8045

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8045

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8045

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8045

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8045

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8045

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8045

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8045

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8045

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8045

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8045

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8045

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8045

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8045

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8045

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8045

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8045

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8045

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8045

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8045

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8045

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8045

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8045

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8045

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8045

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8045

commit: d429d9c

@codspeed-hq

codspeed-hq Bot commented Aug 11, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 13.55%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
❌ 11 (👁 11) regressed benchmarks
✅ 165 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths not-found (react) 414.1 KB 398.2 KB +3.99%
Memory mem server server-fn-churn (vue) 331.7 KB 320.2 KB +3.59%
Memory mem server error-paths error (react) 1,020.9 KB 988 KB +3.33%
Memory mem server server-fn-churn (react) 355.8 KB 344.6 KB +3.23%
👁 Simulation ssr request loop (solid) 434.1 ms 449.4 ms -3.41%
👁 Simulation ssr server-fn during document ssr (vue) 668.9 ms 690.6 ms -3.14%
👁 Memory mem server error-paths redirect (solid) 379.9 KB 393.1 KB -3.35%
👁 Memory mem server peak-large-page (solid) 1.1 MB 1.2 MB -8.29%
👁 Memory mem server error-paths not-found (vue) 777.5 KB 2,370.8 KB -67.21%
👁 Memory mem server error-paths unmatched (react) 422.5 KB 702.4 KB -39.84%
👁 Memory mem server request-churn (react) 679.8 KB 706.5 KB -3.78%
👁 Memory mem client navigation-churn (vue) 1.6 MB 1.7 MB -3.62%
👁 Memory mem client unique-location-churn (vue) 1.3 MB 1.3 MB -3.61%
👁 Memory mem client navigation-churn (solid) 693.2 KB 914 KB -24.16%
👁 Memory mem client unique-location-churn (solid) 426.5 KB 482.4 KB -11.6%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/outlet-fallback-warning (d429d9c) with main (7e93431)

Open in CodSpeed

@Sheraff
Sheraff merged commit f500760 into main Aug 12, 2026
26 checks passed
@Sheraff
Sheraff deleted the fix/outlet-fallback-warning branch August 12, 2026 07:53
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blank screen for the whole navigation when a route's pendingComponent renders <Outlet /> (changed in 1.170.19)

1 participant