Skip to content

perf(7292): Remove LegacyI18nProvider (legacy context bridge) and LegacyMetaMetricsProvider#43483

Open
DDDDDanica wants to merge 5 commits into
mainfrom
perf/7292-provider-refactor
Open

perf(7292): Remove LegacyI18nProvider (legacy context bridge) and LegacyMetaMetricsProvider#43483
DDDDDanica wants to merge 5 commits into
mainfrom
perf/7292-provider-refactor

Conversation

@DDDDDanica

@DDDDDanica DDDDDanica commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

React 18 emits childContextTypes deprecation warnings for LegacyI18nProvider in ui/contexts/i18n.js. This class component bridges I18nContext (modern createContext) into the old childContextTypes API so legacy class components can access this.context.t. Warning appears in ~795 test files.

Also the same pattern, LegacyMetaMetricsProvider in ui/contexts/metametrics.tsx bridges MetaMetricsContext into legacy childContextTypes. Warning appears in ~782 test files.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/7292

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.

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 LegacyI18nProvider and LegacyMetaMetricsProvider, which bridged modern createContext into deprecated childContextTypes / getChildContext (React 18 warnings in large test suites).

i18n: Class components now use static contextType = I18nContext and treat context as the t function directly (const t = this.context / this.context('key')) instead of this.context.t. I18nProvider in ui/contexts/i18n.js is simplified (no legacy wrapper).

MetaMetrics: Components that used legacy this.context.trackEvent get trackEvent via props from thin functional wrappers using useContext(MetaMetricsContext) (e.g. PermissionPageContainer, Home, UnlockPage, ConfirmEncryptionPublicKey, TransactionListItemDetails container). UnlockPage drops withMetaMetrics in favor of that wrapper pattern.

App shell & tests: Storybook, ui/pages/index.js, and render helpers no longer nest legacy providers; tests wrap with I18nContext / MetaMetricsContext only where needed.

Reviewed by Cursor Bugbot for commit 5a70d5b. Bugbot is set up for automated code reviews on this repo. Configure here.

@DDDDDanica DDDDDanica self-assigned this Jun 12, 2026
@github-actions

Copy link
Copy Markdown
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.

@mm-token-exchange-service

mm-token-exchange-service Bot commented Jun 12, 2026

Copy link
Copy Markdown

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (1 files, +3 -6)
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 send-utils/
          • 📁 send-content/
            • 📁 add-recipient/
              • 📄 domain-input.component.js +3 -6

👨‍🔧 @MetaMask/core-extension-ux (5 files, +114 -51)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 transaction-list-item-details/
          • 📄 transaction-list-item-details.component.js +6 -7
          • 📄 transaction-list-item-details.container.js +10 -2
    • 📁 pages/
      • 📁 home/
        • 📄 home.component.test.tsx +5 -10
        • 📄 home.component.tsx +92 -25
      • 📁 settings/
        • 📁 experimental-tab/
          • 📄 experimental-tab.test.tsx +1 -7

💎 @MetaMask/metamask-assets (1 files, +0 -4)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 import-token/
          • 📁 token-list/
            • 📄 token-list.component.js +0 -4

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LegacyI18nProvider and LegacyMetaMetricsProvider and stop mounting them in the main app provider tree.
  • Refactor multiple class components to receive t / trackEvent via props or contextType, 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.

Comment on lines 27 to 31
import { MetaMetricsContext } from '../../../contexts/metametrics';

export default class TransactionListItemDetails extends PureComponent {
static contextTypes = {
t: PropTypes.func,
trackEvent: PropTypes.func,
};
static contextType = MetaMetricsContext;

Comment thread ui/pages/unlock-page/unlock-page.component.tsx
@mm-token-exchange-service

Copy link
Copy Markdown
Builds ready [5a70d5b]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 13 pass · 🟡 12 warn · 🔴 0 fail)

Baseline (latest main): 9d6dfe8 | Date: 6/12/2026 | Pipeline: 27425570263 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: -15%
  • loadNewAccount/total: -15%
  • confirmTx/lcp: +16%
  • bridgeUserActions/longTaskCount: +100%
  • bridgeUserActions/longTaskTotalDuration: +64%
  • bridgeUserActions/longTaskMaxDuration: +13%
  • bridgeUserActions/tbt: +30%
  • loadNewAccount/load_new_account: +47%
  • loadNewAccount/total: +47%
  • loadNewAccount/inp: +23%
  • loadNewAccount/fcp: -49%
  • loadNewAccount/lcp: +1114%
  • confirmTx/confirm_tx: +12%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/total: +12%
  • confirmTx/inp: -20%
  • confirmTx/lcp: +1185%
  • bridgeUserActions/bridge_load_page: +103%
  • bridgeUserActions/bridge_load_asset_picker: +110%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +178%
  • bridgeUserActions/inp: -22%
  • bridgeUserActions/lcp: +1132%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 2.1s
  • 🟡 confirmTx/FCP: p75 1.8s
  • 🟡 confirmTx/FCP: p75 1.9s
  • 🟡 bridgeUserActions/FCP: p75 1.9s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/firstPaint: +14%
  • startupStandardHome/lcp: +13%
  • startupPowerUserHome/domInteractive: +22%
  • startupPowerUserHome/backgroundConnect: +13%
  • startupPowerUserHome/firstReactRender: +17%
  • startupPowerUserHome/setupStore: +25%
  • startupPowerUserHome/numNetworkReqs: -19%
  • startupPowerUserHome/longTaskCount: +21%
  • startupPowerUserHome/longTaskTotalDuration: +13%
  • startupPowerUserHome/longTaskMaxDuration: +11%
  • startupPowerUserHome/tbt: +10%
  • startupStandardHome/uiStartup: +14%
  • startupStandardHome/load: +13%
  • startupStandardHome/domContentLoaded: +13%
  • startupStandardHome/domInteractive: +26%
  • startupStandardHome/backgroundConnect: +20%
  • startupStandardHome/firstReactRender: +19%
  • startupStandardHome/initialActions: +11%
  • startupStandardHome/loadScripts: +13%
  • startupStandardHome/setupStore: +33%
  • startupStandardHome/inp: +108%
  • startupStandardHome/fcp: +10%
  • startupStandardHome/lcp: +14%
  • startupPowerUserHome/uiStartup: +14%
  • startupPowerUserHome/domInteractive: +12%
  • startupPowerUserHome/backgroundConnect: -12%
  • startupPowerUserHome/lcp: +14%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🔴 startupPowerUserHome/INP: p75 544ms
  • 🟡 startupPowerUserHome/LCP: p75 3.2s
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 total
assetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
sendTransactions
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/doneButtonToHomeScreen: -87%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -98%
  • onboardingImportWallet/longTaskCount: -77%
  • onboardingImportWallet/longTaskTotalDuration: -94%
  • onboardingImportWallet/longTaskMaxDuration: -91%
  • onboardingImportWallet/tbt: -100%
  • onboardingImportWallet/total: -86%
  • onboardingNewWallet/doneButtonToAssetList: -24%
  • onboardingNewWallet/longTaskCount: -44%
  • onboardingNewWallet/longTaskTotalDuration: -45%
  • onboardingNewWallet/longTaskMaxDuration: -12%
  • onboardingNewWallet/tbt: -41%
  • onboardingNewWallet/total: -20%
  • solanaAssetDetails/assetClickToPriceChart: -63%
  • solanaAssetDetails/longTaskCount: -100%
  • solanaAssetDetails/longTaskTotalDuration: -100%
  • solanaAssetDetails/longTaskMaxDuration: -100%
  • solanaAssetDetails/tbt: -100%
  • solanaAssetDetails/total: -63%
  • solanaAssetDetails/inp: +10%
  • solanaAssetDetails/cls: -93%
  • importSrpHome/loginToHomeScreen: -20%
  • importSrpHome/homeAfterImportWithNewWallet: -38%
  • importSrpHome/longTaskCount: -37%
  • importSrpHome/longTaskTotalDuration: -45%
  • importSrpHome/longTaskMaxDuration: -29%
  • importSrpHome/tbt: -46%
  • importSrpHome/total: -35%
  • importSrpHome/inp: -40%
  • importSrpHome/fcp: -17%
  • importSrpHome/cls: -34%
  • sendTransactions/openSendPageFromHome: +12%
  • sendTransactions/selectTokenToSendFormLoaded: +14%
  • sendTransactions/inp: -40%
  • sendTransactions/fcp: +14%
  • sendTransactions/cls: -35%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 sendTransactions/FCP: p75 2.1s
  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 solanaAssetDetails/FCP: p75 1.9s
  • 🟡 importSrpHome/FCP: p75 2.0s
  • 🟡 sendTransactions/FCP: p75 1.9s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: +11%
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 102.41 KiB (1.51%)
  • ui: 56.76 KiB (0.5%)
  • common: 293.27 KiB (2.22%)

@DDDDDanica DDDDDanica marked this pull request as ready for review June 12, 2026 16:36
@DDDDDanica DDDDDanica requested review from a team as code owners June 12, 2026 16:36
itsyoboieltr
itsyoboieltr previously approved these changes Jun 12, 2026

@Prithpal-Sooriya Prithpal-Sooriya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assets CO LGTM

@DDDDDanica DDDDDanica enabled auto-merge June 12, 2026 16:54
n3ps
n3ps previously approved these changes Jun 12, 2026
@DDDDDanica DDDDDanica added this pull request to the merge queue Jun 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 12, 2026
…amask-extension into perf/7292-provider-refactor
n3ps
n3ps previously approved these changes Jun 13, 2026
itsyoboieltr
itsyoboieltr previously approved these changes Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants