perf(7292): Remove LegacyI18nProvider (legacy context bridge) and LegacyMetaMetricsProvider#43483
perf(7292): Remove LegacyI18nProvider (legacy context bridge) and LegacyMetaMetricsProvider#43483DDDDDanica wants to merge 5 commits into
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. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (1 files, +3 -6)
👨🔧 @MetaMask/core-extension-ux (5 files, +114 -51)
💎 @MetaMask/metamask-assets (1 files, +0 -4)
|
4c58e5d to
9795a9a
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the legacy childContextTypes bridge providers (LegacyI18nProvider and LegacyMetaMetricsProvider) to eliminate React 18 deprecation warnings, and migrates a set of UI components/tests/storybook helpers to consume I18nContext / MetaMetricsContext via useContext (or contextType) instead.
Changes:
- Remove
LegacyI18nProviderandLegacyMetaMetricsProviderand stop mounting them in the main app provider tree. - Refactor multiple class components to receive
t/trackEventvia props orcontextType, using wrapper function components where needed. - Update tests and Storybook decorators/helpers to no longer rely on legacy providers.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/pages/unlock-page/unlock-page.component.tsx | Replaces legacy context usage with a wrapper that injects t and MetaMetrics methods from modern contexts. |
| ui/pages/settings/experimental-tab/experimental-tab.test.tsx | Removes LegacyMetaMetricsProvider wrapper in test render. |
| ui/pages/index.js | Stops mounting legacy i18n/metametrics bridge providers in the app provider tree and error page. |
| ui/pages/home/home.component.test.tsx | Removes legacy providers from test wrapper, relying on modern context providers directly. |
| ui/pages/home/home.component.js | Wraps the class component with a function component that injects t and trackEvent from modern contexts. |
| ui/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js | Wraps class component to inject t and trackEvent from modern contexts. |
| ui/contexts/metametrics.tsx | Deletes LegacyMetaMetricsProvider implementation; keeps modern context + withMetaMetrics HOC. |
| ui/contexts/i18n.js | Deletes LegacyI18nProvider; simplifies I18nProvider children handling. |
| ui/components/ui/page-container/page-container-footer/page-container-footer.component.js | Switches from legacy contextTypes to static contextType = I18nContext. |
| ui/components/ui/editable-label/editable-label.js | Switches from legacy contextTypes to static contextType = I18nContext and updates call sites. |
| ui/components/app/transaction-list-item-details/transaction-list-item-details.component.js | Attempts to replace legacy context usage with contextType (but currently mis-wires i18n vs MetaMetrics context). |
| ui/components/app/permission-page-container/permission-page-container.component.js | Wraps class component to inject t and trackEvent from modern contexts. |
| ui/components/app/modals/hide-token-confirmation-modal/hide-token-confirmation-modal.js | Switches i18n usage to static contextType = I18nContext. |
| ui/components/app/connected-sites-list/connected-sites-list.component.js | Switches i18n usage to static contextType = I18nContext. |
| ui/components/app/connected-accounts-list/connected-accounts-list.component.js | Switches i18n usage to static contextType = I18nContext. |
| test/lib/render-helpers.js | Removes LegacyI18nProvider from test localization wrapper. |
| test/lib/render-helpers-navigate.js | Removes legacy providers from navigation test wrapper and localization wrapper. |
| .storybook/preview.js | Removes LegacyI18nProvider from Storybook decorator tree. |
| .storybook/metametrics.js | Removes LegacyMetaMetricsProvider from Storybook provider wrapper. |
| .storybook/i18n.js | Removes Storybook LegacyI18nProvider implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { MetaMetricsContext } from '../../../contexts/metametrics'; | ||
|
|
||
| export default class TransactionListItemDetails extends PureComponent { | ||
| static contextTypes = { | ||
| t: PropTypes.func, | ||
| trackEvent: PropTypes.func, | ||
| }; | ||
| static contextType = MetaMetricsContext; | ||
|
|
…acyMetaMetricsProvider
9795a9a to
2f5ff78
Compare
2f5ff78 to
4089f61
Compare
…acyMetaMetricsProvider
4089f61 to
5a70d5b
Compare
Builds ready [5a70d5b]
⚡ Performance Benchmarks (Total: 🟢 13 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…amask-extension into perf/7292-provider-refactor
c5274c0
Co-authored-by: Cursor <cursoragent@cursor.com>
Description
React 18 emits
childContextTypesdeprecation warnings forLegacyI18nProviderinui/contexts/i18n.js. This class component bridgesI18nContext(moderncreateContext) into the oldchildContextTypesAPI so legacy class components can accessthis.context.t. Warning appears in ~795 test files.Also the same pattern,
LegacyMetaMetricsProviderinui/contexts/metametrics.tsxbridgesMetaMetricsContextinto legacychildContextTypes. Warning appears in ~782 test files.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/7292
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches many UI surfaces (connect, permissions, home, unlock, transactions) for i18n and analytics wiring; behavior should be equivalent but regressions are possible in untested class-component paths.
Overview
Removes
LegacyI18nProviderandLegacyMetaMetricsProvider, which bridged moderncreateContextinto deprecatedchildContextTypes/getChildContext(React 18 warnings in large test suites).i18n: Class components now use
static contextType = I18nContextand treat context as thetfunction directly (const t = this.context/this.context('key')) instead ofthis.context.t.I18nProviderinui/contexts/i18n.jsis simplified (no legacy wrapper).MetaMetrics: Components that used legacy
this.context.trackEventgettrackEventvia props from thin functional wrappers usinguseContext(MetaMetricsContext)(e.g.PermissionPageContainer,Home,UnlockPage,ConfirmEncryptionPublicKey,TransactionListItemDetailscontainer).UnlockPagedropswithMetaMetricsin favor of that wrapper pattern.App shell & tests: Storybook,
ui/pages/index.js, and render helpers no longer nest legacy providers; tests wrap withI18nContext/MetaMetricsContextonly where needed.Reviewed by Cursor Bugbot for commit 5a70d5b. Bugbot is set up for automated code reviews on this repo. Configure here.