feat(tabs): enhance HomepageDiscoveryTabs tests and context stability
Description
Memoizes the TabIconAnimationContext provider value in HomepageDiscoveryTabs so tab icon consumers do not receive a new context object on unrelated parent rerenders. This keeps the Reanimated SharedValue plumbing intact while reducing unnecessary context invalidation for the homepage discovery tab bar.
This also moves the existing React compiler suppression onto the exact Reanimated shared-value mutation it documents, and adds a focused regression test that verifies the provider value remains referentially stable across unrelated rerenders.
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TMCU-882
Manual testing steps
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
Screenshots/Recordings
Before
After
Pre-merge author checklist
- [x] I've followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards.
- [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 format if applicable
- [x] I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
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
- See
trace()for usage andaddTokenfor an example
- See
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 Small React performance/context fix with no auth, data, or API changes; behavior is unchanged aside from fewer context updates.
Overview
HomepageDiscoveryTabsnow memoizes theTabIconAnimationContextprovider value withuseMemo, so tab icon consumers keep the same context object reference when the parent rerenders for unrelated props (e.g.walletHeaderOffset) instead of getting a fresh inline object every time.The React compiler
eslint-disablefor ReanimatedSharedValuemutation is relocated to sit on theiconCollapseProgress.value = withTiming(...)line it documents.Tests mock
useSharedValuefor a stable shared value and add a regression case that asserts the context value is referentially stable across such rerenders.Reviewed by Cursor Bugbot for commit 84b32cbf9630094d53d0f1d3ac393514a0373f5d. Bugbot is set up for automated code reviews on this repo. Configure here.
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.
PR template — items to address before "Ready for review"
Warnings — informational, address before merging:
Manual testing stepsstill contain template content (the Gherkin example title or a[...]placeholder). Replace with real steps, or writeN/A — <reason>.Screenshots/Recordingssection is empty. Add an image/video for user-facing changes, logs/console output for non-user-facing changes, or writeN/Aif no evidence is applicable.Pre-merge author checklisthas unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — seedocs/readme/ready-for-review.md.
See docs/readme/ready-for-review.md for the full Definition of Ready for Review.
🔍 Smart E2E Test Selection
- Selected E2E tags: SmokeWalletPlatform
- Selected Performance tags: None (no tests recommended)
- Risk Level: low
- AI Confidence: 88%
click to see 🤖 AI reasoning details
E2E Test Selection: The changes are confined to HomepageDiscoveryTabs.tsx and its test file. The functional change is wrapping the TabIconAnimationContext.Provider value in useMemo to stabilize the context reference across re-renders — a standard React optimization pattern. The eslint-disable comment was also moved to a more specific location (cosmetic). The test file adds a unit test to verify the memoization behavior.
This component is the Trending/Discovery tabs on the wallet homepage. SmokeWalletPlatform covers the Trending discovery tab including search, browsing content feeds (Predictions, Tokens, Perps, Sites sections), and browser navigation integration. Since the change touches the container component for these tabs, SmokeWalletPlatform is the appropriate tag to validate the change doesn't break the Trending tab UI or navigation.
No other tags are needed: the change doesn't affect confirmations, network management, swaps, staking, accounts, snaps, or any other feature area. The risk is low since it's a pure React optimization (useMemo) with no logic changes.
Performance Test Selection: The change adds useMemo to stabilize a context value reference, which is a micro-optimization that prevents unnecessary re-renders of context consumers. While this is technically a performance improvement, it's too minor to warrant running dedicated performance tests. The change doesn't affect any of the measured performance scenarios (app launch, onboarding, login, swaps, asset loading, account list, predict, perps). No performance spec files were changed.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code
No release label on PR. Adding release label release-8.2.0 on PR, as PR was added to branch 8.2.0 when release was cut.