Feat: React Native Upgrade 0.81.5 #29156
Conversation
- Convert defaultProps to default params on function components (React 19 ignores defaultProps)
- Add optional chaining for this.context?.colors in StyledButton class components
- Update eciesjs API usage in key-manager.ts (toBytes → compressed)
- Add pretty-format/react-is resolution to ^19.0.0 for snapshot serialization
- Fix testSetup.js: BottomSheet mock (goBack on close), react-native-modal mock (passthrough testID), NativeAnimatedHelper improvements
- Replace jest.resetAllMocks() with jest.clearAllMocks() where it destroyed global mock implementations
- Add await act(async () => { cleanup() }) for React 19 async cleanup flushing
- Update assertions for React 19 behavior (disabled buttons block events, fiber objects)
- Replace findByType(TouchableOpacity) with getByTestId() queries
- Update Reanimated mocks (withTiming, runOnJS, createAnimatedComponent)
- Fix missing mock data/props across ~100 test files
Updated 462 snapshot files to reflect React 19 element serialization changes (react-is 19.x with pretty-format).
The global testSetup.js already mocks react-native-modal. Remove redundant local mocks from ApprovalModal, FlowLoaderModal, and TemplateConfirmationModal tests. Also fix resetAllMocks → clearAllMocks in ApprovalModal.
React 19 ignores defaultProps on function components. Convert all remaining instances to ES6 default parameters in destructured props. Reference-type defaults (arrays, objects) are hoisted to module-level constants to avoid re-creation on every render. Only class components (EthereumAddress, FadeOutOverlay) retain defaultProps, which React 19 still supports.
The global testSetup.js already calls setUpTests() which provides the standard reanimated mock environment. Remove 5 test files that had unnecessary local overrides. 6 files retain their local mocks because they need test-specific behavior (custom shared value states, createAnimatedComponent passthrough, or tightly coupled mock assertions).
Two separate blocks patched the same module. Consolidated into a single Object.defineProperty getter approach which is more robust than direct assignment.
…rrides Add configureReanimatedLogger and ReanimatedLogLevel to the global reanimated setup in testSetup.js. Simplify PerpsOrderView and useColorPulseAnimation local mocks by removing the now-redundant logger config.
Component doesn't use Redux — plain render() from RNTL suffices. The other 10 files that switched to renderWithProvider genuinely need it because child components access the Redux store.
…pshot() Revert verbose toJSON destructuring pattern back to the simpler expect(component).toMatchSnapshot() — both produce identical snapshots since RNTL's render result has a toJSON() that pretty-format calls automatically. 355 test files simplified, 26 files correctly kept toJSON() where it was used for non-snapshot purposes (null checks, serialization).
Add tests/performance/ to testPathIgnorePatterns in jest.config.js. These are Playwright tests that should only run via npx playwright test.
RNTL's fireEvent already wraps state updates in act internally,
making await act(async () => { fireEvent.press(...) }) redundant.
Removed 141 unnecessary wrappers across 18 test files. Kept act
wrappers where they're genuinely needed: cleanup(), timer advances,
hook result.current calls, and fireEvent triggering async operations
(ResetPassword, FooterButtonGroup, PerpsSlider).
|
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. |
|
Caution MetaMask internal reviewing guidelines:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…me/Jest ESLint deps Adds browserify-zlib for Metro extraNodeModules zlib shim. Removes enzyme stack and eslint-plugin-jest which were unused in the codebase.
patch-package failed in CI when @types/enzyme is not installed; the types package is no longer a dependency. Made-with: Cursor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - draft PR All E2E tests pre-selected. |
| "react-native-in-app-review": "^4.3.3", | ||
| "react-native-inappbrowser-reborn": "^3.7.0", | ||
| "react-native-jazzicon": "^0.1.2", | ||
| "react-native-keyboard-aware-scroll-view": "^0.9.5", | ||
| "react-native-keyboard-controller": "^1.20.3", | ||
| "react-native-keyboard-controller": "1.18.5", |
There was a problem hiding this comment.
Why this lib version was downgraded? 🤔
Description
Changelog
Dependencies & Runtime
React Native: 0.76.9 (patched Yarn resolution on main) → 0.81.5
React: 18.3.1 → 19.1.0
@types/react: ^18.2.6 → ^19.1.0
Expo: ~52.x → 54.0.33
React Native Toolchain
@react-native-community/cli (and platform packages): 15.x → 20.0.0
@react-native/metro-config: 0.76.9 → 0.81.5 (aligned with RN 0.81.5)
Testing
@testing-library/react-native: ^13.2.0 tests adjusted where behavior/matchers differ under React 19 / RN 0.81 (document any non-obvious test fixes in PR body).
Enzyme: Legacy enzyme / adapters still present where needed; migration toward RTL continues; @types/enzyme includes deprecation-oriented patch to steer new work to RTL.
CHANGELOG entry: Upgrade React Native to 0.81.5 and related dependencies.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist