Skip to content

fix: allow Framework Mode route components to be passed to createRoutesStub#14892

Merged
brophdawg11 merged 1 commit into
devfrom
fix/createRoutesStub-component-type
Mar 18, 2026
Merged

fix: allow Framework Mode route components to be passed to createRoutesStub#14892
brophdawg11 merged 1 commit into
devfrom
fix/createRoutesStub-component-type

Conversation

@brophdawg11
Copy link
Copy Markdown
Contributor

Component, HydrateFallback, and ErrorBoundary in StubRouteExtensions were typed as React.ComponentType<RouteComponentProps> (and equivalents), which was too narrow

Framework Mode components annotated with Route.ComponentProps have more specific params and matches types — TypeScript's contravariance on function parameters means they aren't assignable to the broader type

Widening these to React.ComponentType<any> fixes the type error while remaining safe at runtime, since withComponentProps always injects the correct props from router hooks regardless of the component's declared type.

Fixes #14886

…esStub

Route components typed with Route.ComponentProps have more specific
params and matches types. Due to TypeScript contravariance on function
parameters, they were not assignable to React.ComponentType<RouteComponentProps>.

Widen Component, HydrateFallback, and ErrorBoundary in StubRouteExtensions
to React.ComponentType<any> so any route component can be passed without
a type error.

Fixes #14886

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: b716a56

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brophdawg11 brophdawg11 merged commit 8c3c7ce into dev Mar 18, 2026
6 checks passed
@brophdawg11 brophdawg11 deleted the fix/createRoutesStub-component-type branch March 18, 2026 16:30
@github-actions
Copy link
Copy Markdown
Contributor

🤖 Hello there,

We just published version 7.13.2-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Hello there,

We just published version 7.13.2 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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.

Route component cannot be passed as-is to createRoutesStub when using ComponentProps

1 participant