Skip to content

ref: Pass matches to recreateRoute for react-router-dom migration#117457

Closed
ryan953 wants to merge 5 commits into
masterfrom
ryan953/ref-pass-matches-to-recreateRoute
Closed

ref: Pass matches to recreateRoute for react-router-dom migration#117457
ryan953 wants to merge 5 commits into
masterfrom
ryan953/ref-pass-matches-to-recreateRoute

Conversation

@ryan953

@ryan953 ryan953 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Wire useMatches() from react-router-dom into all recreateRoute call sites. This prepares recreateRoute to use the new router's match data instead of relying solely on legacy route objects. Update tests to construct matches and derive routes from them.

Turns out this was annoying enough to review, without the subsequent changes to recreateRoute, that i decided to push it on it's own.

Wire useMatches() from react-router-dom into all recreateRoute call
sites. This prepares recreateRoute to use the new router's match data
instead of relying solely on legacy route objects.

Update tests to construct matches and derive routes from them.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@ryan953 ryan953 requested review from a team as code owners June 11, 2026 19:36
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

Metric Before After Delta
Coverage 93.70% 93.70% ±0%
Typed 132,918 132,938 🟢 +20
Untyped 8,937 8,935 🟢 -2
🔍 7 new type safety issues introduced

any-typed symbols (5 new)

File Line Detail
static/app/utils/recreateRoute.tsx 8 m.handle as any (as-any)
static/app/utils/recreateRoute.tsx 39 to as any (as-any)
static/app/utils/recreateRoute.tsx 39 handle as any (as-any)
static/app/utils/recreateRoute.tsx 51 routes (var)
static/app/views/settings/components/settingsBreadcrumb/projectCrumb.tsx 27 routes (var)

Type assertions (as) (2 new)

File Line Detail
static/app/views/settings/components/settingsBreadcrumb/index.tsx 30 as RouteWithName[]matchesToRoutes(matches) as RouteWithName[]
static/app/views/settings/components/settingsBreadcrumb/projectCrumb.tsx 28 as RouteWithNameroutes[routeIndex] as RouteWithName

This is informational only and does not block the PR.

Pick<RouteComponentProps, 'params' | 'routes'>;
} & Plugin;

class ProjectPluginRow extends PureComponent<Props> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Class component down.

Export matchesToRoutes from recreateRoute so callers can derive routes
from matches. Make routes optional in Options — when omitted, routes
are derived from matches internally. This allows callers to depend on
matches only, advancing the react-router-dom migration.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Remove `routes` from the Options type and derive it internally via
`matchesToRoutes(matches)`. Replace `routes.indexOf(to)` with
`findRouteInMatches` which compares route properties against match
handles — this works because both caller and callee routes originate
from the same handle objects via shallow spread.

Remove `useRoutes()` from all callers that no longer need it.
Switch settingsBreadcrumb to use `matchesToRoutes(matches)` instead
of `useRoutes()` for its route iteration.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Replace `routes` and `route` props with `routeIndex` in
SettingsBreadcrumbProps. Child components (ProjectCrumb, TeamCrumb)
now derive routes from matches locally via matchesToRoutes.

Replace BreadcrumbDropdown's `route` prop with an optional
`routeName` string since it only used `route.name` as a fallback
display label.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Replace mocked useRoutes with proper nested route children that have
handle properties, so useMatches returns the route metadata that
recreateRoute now reads from matches.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@ryan953 ryan953 marked this pull request as ready for review June 12, 2026 19:46
@ryan953 ryan953 closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant