ref: Pass matches to recreateRoute for react-router-dom migration#117457
Closed
ryan953 wants to merge 5 commits into
Closed
ref: Pass matches to recreateRoute for react-router-dom migration#117457ryan953 wants to merge 5 commits into
ryan953 wants to merge 5 commits into
Conversation
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>
Contributor
📊 Type Coverage Diff
🔍 7 new type safety issues introduced
Type assertions (
This is informational only and does not block the PR. |
ryan953
commented
Jun 11, 2026
| Pick<RouteComponentProps, 'params' | 'routes'>; | ||
| } & Plugin; | ||
|
|
||
| class ProjectPluginRow extends PureComponent<Props> { |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.