-
Notifications
You must be signed in to change notification settings - Fork 5.4k
refactor(556x): migrate unlock, deeplink, defi page to react-router-dom-v5-compat #37586
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
base: main
Are you sure you want to change the base?
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Migration break: use navigate instead of history.replace
The onResetWallet method references this.props.history.replace(DEFAULT_ROUTE) on line 472, but the history prop was removed and replaced with navigate in this migration. This will cause a runtime error when the method is invoked. It should be changed to this.props.navigate(DEFAULT_ROUTE, { replace: true }).
ui/pages/unlock-page/unlock-page.component.js#L467-L473
metamask-extension/ui/pages/unlock-page/unlock-page.component.js
Lines 467 to 473 in 7a79714
| onResetWallet = async () => { | |
| this.setState({ showLoginErrorModal: false }); | |
| await this.props.resetWallet(); | |
| await this.props.forceUpdateMetamaskState(); | |
| this.props.history.replace(DEFAULT_ROUTE); | |
| }; |
e8431e9 to
ac5edda
Compare
Builds ready [6503e55]
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| </Router>, | ||
| <UnlockPage forceUpdateMetamaskState={mockForceUpdateMetamaskState} />, | ||
| store, | ||
| { pathname }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Duplicate Test Names Confuse Test Runner
Duplicate test case with identical name should show login error modal when authentication error is thrown exists at lines 258-297 and 299-335. The tests have the same name and nearly identical implementation, which will cause test runner confusion and makes one test unreachable.
aef7c41 to
47ba5a0
Compare
| /> | ||
| )} | ||
| /> | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Nested Routes Created by Authenticated HOC Wrapping
Nested Route components created by wrapping Authenticated inside a Route render prop. The Authenticated HOC returns a Route component when authenticated, creating a Route inside a Route. This should use AuthenticatedV5Compat instead, which returns children directly without wrapping in a Route, or the outer Route render prop should be removed.
ui/pages/routes/routes.component.tsx
Outdated
| params={match.params} | ||
| /> | ||
| )} | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Nested Routes Created by Authenticated Wrapper
Nested Route components created by wrapping Authenticated inside a Route render prop. The Authenticated HOC returns a Route component when authenticated, creating a Route inside a Route. This should use AuthenticatedV5Compat instead, which returns children directly without wrapping in a Route, or the outer Route render prop should be removed.
Builds ready [47ba5a0]
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [33daab7]
UI Startup Metrics (1166 ± 88 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
d68edca to
0f8e39b
Compare
Builds ready [0f8e39b]
UI Startup Metrics (1265 ± 111 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
Migrate migrate unlock, deeplink, defi page and MetaMetricsContext to
react-router-dom-v5-compatChangelog
CHANGELOG entry: null
Related issues
Fixes: part of https://github.com/MetaMask/MetaMask-planning/issues/3261
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Migrates multiple pages to react-router-dom-v5-compat, adds InitializedV5Compat, adapts routing to pass navigate/params, updates MetaMetrics page matching, and refreshes tests/stories accordingly.
react-router-dom-v5-compatacross pages; useNavigateinstead ofRedirect.ui/pages/routes/routes.component.tsx, bridge v5historyto v5-compatnavigateviacreateV5CompatNavigate, render components via Route children, and passnavigate/params/locationas needed. RenderToastMasterwith explicitlocationprop.InitializedV5CompatHOC to guard routes needing onboarding completion.ui/contexts/metametrics.js, switch toreact-router-dom-v5-compatand loopgetPaths()withmatchPath(v6-style signature) to find the first match for page tracking.ui/pages/unlock-page/*: Replacehistorywithnavigate; read redirect fromlocation.state.fromornavState.from; containers usewithRouterHooksanduseNavState; docs/stories updated.ui/pages/deep-link/deep-link.tsx: Acceptlocationvia props (from Route) instead ofuseLocation.ui/pages/defi/components/defi-details-page.tsx: Acceptnavigate/params; replaceRedirect/history.pushwithNavigate/navigate.ui/pages/keychains/reveal-seed.js: Acceptnavigate/keyringId; replacehistory.goBackwithnavigate(-1); add PropTypes.ui/pages/lock/*: Usenavigate(+withRouterHooks) in component/container.render-helpers-navigate, mockreact-router-dom-v5-compathooks, pass new props (navigate,params,location), and adjust snapshots/behaviors accordingly.Written by Cursor Bugbot for commit 0f8e39b. This will update automatically on new commits. Configure here.