Skip to content

chore: migrate StackNavigationProp types to native-stack equivalents#32119

Merged
weitingsun merged 19 commits into
mainfrom
wsun/clean-up-react-navigation-stack
Jun 25, 2026
Merged

chore: migrate StackNavigationProp types to native-stack equivalents#32119
weitingsun merged 19 commits into
mainfrom
wsun/clean-up-react-navigation-stack

Conversation

@weitingsun

@weitingsun weitingsun commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Description

Replaces remaining @react-navigation/stack type usage with native-stack-aligned types now that the app runs on createNativeStackNavigator. This PR is type-only for production code — no navigator or screen transition behavior changes.

  • Migrate StackNavigationProp call sites to AppNavigationProp, NavigationProp, or NativeStackNavigationProp as appropriate
  • Update AppNavigationProp to extend NativeStackNavigationProp so stack APIs (replace, push, pop) type-check correctly
  • Update test/storybook render helpers to use createNativeStackNavigator

Changelog

CHANGELOG entry:null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-586

Manual testing steps

N/A - the changes are limited to tests and type changes, no functional changes

Screenshots/Recordings

n/a

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

Low Risk
Mostly compile-time and test harness changes; the only runtime tweak is deferring Ramp order-history navigation until a sheet closes, which is low risk.

Overview
Finishes the native-stack migration for typing and test infrastructure now that the app uses createNativeStackNavigator: @react-navigation/stack is removed from dependencies and call sites.

Production screens and hooks swap loose StackNavigationProp / ParamListBase usage for AppNavigationProp, AppStackNavigationProp, or NavigationProp from NavigationService/types. AppStackNavigationProp is added for stack-only APIs (replace, push, pop) with the same safe getState() typing as AppNavigationProp. Legacy JS stack navigator option presets in clearStackNavigatorOptions.ts are dropped in favor of clearNativeStackNavigatorOptions.

Tests, Storybook, and shared renderWithProvider / component-view renderers use createNativeStackNavigator and mock react-native-screens in Jest so native-stack mounts cleanly. Ramp Settings defers “View order history” navigation until the bottom sheet onCloseBottomSheet callback runs. Earn withdraw tests press Done before asserting the TRON Unstake button.

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

@weitingsun weitingsun self-assigned this Jun 19, 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.

@metamask-ci metamask-ci Bot added the team-mobile-platform Mobile Platform team label Jun 19, 2026
@weitingsun weitingsun marked this pull request as ready for review June 19, 2026 18:40
@weitingsun weitingsun requested review from a team as code owners June 19, 2026 18:40
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jun 19, 2026
…aMask/metamask-mobile into wsun/clean-up-react-navigation-stack
@weitingsun weitingsun requested a review from a team as a code owner June 19, 2026 19:17
@github-actions github-actions Bot added risk:low AI analysis: low risk and removed risk:medium AI analysis: medium risk labels Jun 19, 2026
@weitingsun weitingsun marked this pull request as draft June 20, 2026 03:03
jpuri
jpuri previously approved these changes Jun 22, 2026

@Cal-L Cal-L 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.

LGTM

@montelaidev montelaidev 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.

Accounts changes looks ok

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

4 tests failed · 20 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

❌ Failed Tests (4)

@Accounts-team

Test Platform Device Reason Recording
Import SRP with +50 accounts, SRP 1, SRP 2, SRP 3 Android Google Pixel 8 Pro (v14.0) Test error 📹 Watch

@metamask-onboarding-team

Test Platform Device Reason Recording
Account creation after fresh install Android Google Pixel 8 Pro (v14.0) Test error 📹 Watch
Seedless Onboarding: Apple Login New User Android Google Pixel 8 Pro (v14.0) Quality gates exceeded 📹 Watch

@metamask-mobile-platform

Test Platform Device Reason Recording
Cold Start after importing a wallet Android Google Pixel 8 Pro (v14.0) Test error 📹 Watch
✅ Passed Tests (16)
Test Platform Device Duration Team Recording
Cross-chain swap flow - ETH to SOL - 50+ accounts, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 4.88s @swap-bridge-dev-team 📹 Watch
Asset View, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 3.61s @assets-dev-team 📹 Watch
Aggregated Balance Loading Time, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 8.56s @assets-dev-team 📹 Watch
Cold Start: Measure ColdStart To Login Screen Android Google Pixel 8 Pro (v14.0) 4.24s @metamask-mobile-platform 📹 Watch
Swap flow - ETH to LINK, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 3.53s @swap-bridge-dev-team 📹 Watch
Measure Warm Start: Login To Wallet Screen Android Google Pixel 8 Pro (v14.0) 2.13s @metamask-mobile-platform 📹 Watch
Measure Warm Start: Warm Start to Login Screen Android Google Pixel 8 Pro (v14.0) 0.00s @metamask-mobile-platform 📹 Watch
Perps add funds Android Google Pixel 8 Pro (v14.0) 9.91s @mm-perps-engineering-team 📹 Watch
Predict Available Balance - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 1.38s @team-predict 📹 Watch
Connect to Uniswap dapp, edit accounts, choose another account, and skip Solana popup Android Google Pixel 8 Pro (v14.0) 14.47s @metamask-mobile-platform 📹 Watch
Predict Market Details - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 300.01s @team-predict
Predict Deposit - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 12.79s @team-predict 📹 Watch
Measure Cold Start To Onboarding Screen Android Google Pixel 8 Pro (v14.0) 3.44s @metamask-mobile-platform 📹 Watch
Onboarding Import SRP with +50 accounts, SRP 3 Android Google Pixel 8 Pro (v14.0) 6.48s @metamask-onboarding-team 📹 Watch
Perps open position and close it Android Google Pixel 8 Pro (v14.0) 21.88s @mm-perps-engineering-team 📹 Watch
Seedless Onboarding: Google Login New User Android Google Pixel 8 Pro (v14.0) 8.51s @metamask-onboarding-team 📹 Watch

Branch: wsun/clean-up-react-navigation-stack · Build: Normal · Commit: 5bea3d8 · View full run

@github-actions github-actions Bot added risk:high AI analysis: high risk and removed risk:medium AI analysis: medium risk labels Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeSwap, SmokeConfirmations, SmokeMoney, SmokeStake, SmokePredictions, SmokeWalletPlatform, SmokeAccounts, SmokeNetworkAbstractions
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR is a navigation library migration removing @react-navigation/stack and replacing it with @react-navigation/native-stack throughout the codebase. The @react-navigation/stack package is removed from package.json entirely.

Nature of changes:

  • Most changes are TypeScript type-only: replacing StackNavigationProp with AppNavigationProp or AppStackNavigationProp. These have no runtime behavioral impact.
  • Test infrastructure changes: renderWithProvider.tsx, testSetup.js, and tests/component-view/ renderers all migrated to createNativeStackNavigator. These affect unit tests, not E2E tests directly.
  • One functional behavioral change: SettingsModal.tsx in Ramp now navigates to TRANSACTIONS_VIEW inside the onCloseBottomSheet callback (after sheet closes) rather than before. This is a real behavioral change in the Ramp flow.
  • clearStackNavigatorOptions.ts removes the old JS-stack variants, keeping only native-stack options.

Affected feature areas and corresponding tags:

  1. SmokeSwap: Bridge BatchSell modals (BatchSellFinalReviewModal, BatchSellMinimumReceivedInfoModal, BatchSellNetworkFeeInfoModal, BatchSellQuoteDetailsModal, MissingPriceModal, TokenWarningModal) all use navigation. Per tag description, SmokeSwap requires SmokeConfirmations.
  2. SmokeConfirmations: useClearConfirmationOnBackSwipe migrated — this hook handles back-swipe rejection in confirmation flows. Critical path for confirmations.
  3. SmokeMoney: Ramp SettingsModal (behavioral change), ErrorDetailsModal, useTransakRouting, MoneyFirstTimeDepositView, MoneyOnboardingView all affected. Per tag description, SmokeMoney with Add Funds flows requires SmokeSwap and SmokeConfirmations.
  4. SmokeStake: EarnMusdConversionEducationView (Earn/Stake flow) navigation migrated.
  5. SmokePredictions: usePredictBuyActions migrated from StackNavigationProp to NativeStackNavigationProp — this is the core buy action hook for predictions.
  6. SmokeWalletPlatform: useTokenListFilters (Trending), TopTradersSection (Homepage/Trending) navigation migrated.
  7. SmokeAccounts: ManualBackupStep1.types.ts navigation prop type changed — affects SRP backup flow.
  8. SmokeNetworkAbstractions: AddCustomToken navigation migrated (AppStackNavigationProp with replace/push APIs).

Risk assessment: Medium risk. The migration from JS-stack to native-stack changes the underlying navigation implementation. While most changes are type-only, the actual navigator behavior (animations, gesture handling, back navigation) differs between the two implementations. The useClearConfirmationOnBackSwipe hook is particularly sensitive as it handles back-gesture rejection. The SettingsModal behavioral change is a real functional difference. The removal of @react-navigation/stack from package.json means any remaining usage would cause runtime errors.

Performance Test Selection:
The changes are a navigation library migration (removing @react-navigation/stack, using @react-navigation/native-stack). While native-stack is generally more performant than JS-stack, the changes are type-level and infrastructure-level with no direct impact on the performance test scenarios (account list rendering, onboarding, login, swaps, launch, asset loading, predict, perps). The SettingsModal behavioral change is minor and doesn't affect measured performance flows. No performance spec files were changed.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@weitingsun weitingsun added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit 2dc06a8 Jun 25, 2026
203 of 227 checks passed
@weitingsun weitingsun deleted the wsun/clean-up-react-navigation-stack branch June 25, 2026 10:51
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
@metamaskbot metamaskbot added the release-8.1.0 Issue or pull request that will be included in release 8.1.0 label Jun 29, 2026
@gauthierpetetin

Copy link
Copy Markdown
Contributor

No release label on PR. Adding release label release-8.1.0 on PR, as PR was added to branch 8.1.0 when release was cut.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.1.0 Issue or pull request that will be included in release 8.1.0 risk:high AI analysis: high risk size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.