Skip to content

Conversation

MajorLift
Copy link
Contributor

@MajorLift MajorLift commented Aug 12, 2025

Description

Open in GitHub Codespaces

Changelog

CHANGELOG entry:

Related issues

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedreact-router-dom@​5.3.4 ⏵ 6.30.19810073 -999100
Updatedreact-router@​5.3.4 ⏵ 6.30.197 +110076 -799100
Added@​remix-run/​router@​1.23.010010010088100

View full report

github-merge-queue bot pushed a commit that referenced this pull request Aug 13, 2025
…#33276)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## Note for Reviewers

The bulk of the changes in this PR are in
[`ui/pages/routes/routes.component.tsx`](https://github.com/MetaMask/metamask-extension/pull/33276/files#diff-41292899566e5a4241f4b8297aeb1a00057fc694d72ff12a3d9b7102252f59dd).
Unfortunately, GitHub is failing to recognize that this file was renamed
from
[`ui/pages/routes/routes.component.js`](https://github.com/MetaMask/metamask-extension/pull/33276/files#diff-10975e6333c4f017e6def2e4c715c3efd9a92c87f9fa24f105598f101ad66738),
even with a `git mv` commit establishing this fact:
1f91b8c.

- For a side-by-side diff of the two files, you can go to
https://www.diffchecker.com/eITwpTzt/ or
https://diffy.org/diff/d177f182ccb97.
- This issue is also contributing to the PR exceeding our maximum LoC
limit, because all of the lines in `routes.component.tsx` file (751
lines) are being counted as additions, instead of just the changed lines
(454 lines).

## **Motivation**

The `<Routes />` component handles routing and navigation between our
application's pages and url paths. Despite its importance, it remains
written in JavaScript as a class component, and relies on a HOC for
access to Redux state properties and actions, all of which are outdated
patterns.

## **Description**

This commit achieves the following:
1. Migrate `<Routes />` into a functional component that uses hooks, and
can directly interface with the Redux store using selectors and
dispatched actions.
2. Migrate `<Routes />` to strict TypeScript.
3. Adds `useAppSelector`, a typed version of the `useSelector` hook, to
`ui/store/store.ts`.

These changes represent a significant improvement in maintainability,
type safety, and future extensibility. This migration also unblocks the
`react-router` v6 upgrade effort, which requires class components to be
converted to functional components.

## **Related issues**

- Requirement for [react-router v6
upgrade](MetaMask/MetaMask-planning#3261)
- ~See #31459
- Contributes to
MetaMask/MetaMask-planning#5477
- Closes MetaMask/MetaMask-planning#5478
- Followed by #35030

## **Manual testing steps**

1. After installing, check whether all steps of the onboarding flow load
and display without issue.
2. Verify that pages (e.g. Settings) load and display without issue.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Base automatically changed from chore/react-router-v6/250515-convert-Routes-to-function-component to main August 13, 2025 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-extension-platform Extension Platform team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants