-
Notifications
You must be signed in to change notification settings - Fork 5.5k
refactor: Migrate <Routes /> to react-router v6
#35030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Migrate <Routes /> to react-router v6
#35030
Conversation
|
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. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…#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.
|
This PR has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions. |
|
This PR was closed because there has been no follow up activity in 7 days. Thank you for your contributions. |
Description
Changelog
CHANGELOG entry:
Related issues
<Routes />into a TypeScript functional component #33276Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist