Skip to content

Commit 408ab73

Browse files
asalsyscursoragent
andauthored
refactor(predict): remove unnecessary useNavigation generic types (#26564)
## **Description** **Reason for the change:** This is a preparatory change for upgrading the React Navigation library to v6. With global default types now applied to the navigation API, we no longer need to apply generic types to the `useNavigation` hook in most cases. **Improvement/Solution:** - Removed generic types from `useNavigation` hook invocations (now uses default global navigation types) - Applied `NavigationProp<NavigatableRootParamList>` where deeply nested navigation is required - Part of a series of PRs splitting the cleanup by codebase ownership **Note on exceptions:** Generic types may still be needed when navigating to deeper nested stacks. For those instances, we apply a recursive navigation type pattern. **References:** - Parent issue: #23763 - React Navigation nesting docs: https://reactnavigation.org/docs/nesting-navigators/ ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: #23763 (partial) ## **Manual testing steps** ```gherkin Feature: Navigation functionality after useNavigation cleanup Scenario: Predict navigation works correctly Given the app is running And the user is on the Predict section When user navigates to any Predict screen Then the navigation should complete successfully And no TypeScript errors should occur ``` **Additional verification:** - Run `yarn lint:tsc` to verify no TypeScript errors are introduced - Run unit tests for affected components ## **Screenshots/Recordings** N/A - No visual changes (internal refactoring/type cleanup) ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [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](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Primarily a TypeScript typing cleanup and unit-test refactor; runtime behavior should be unchanged, with only light risk of missed compile-time navigation type errors in Predict flows. > > **Overview** > **Predict navigation typing cleanup.** Drops `useNavigation<NavigationProp<...>>()` generics across multiple Predict components/views/hooks in favor of default navigation types, with corresponding import simplifications. > > **Test updates.** Refactors Predict unit tests to use `renderWithProvider` and simpler mocks (notably `PredictActivityDetail`, `PredictHomeFeaturedList`, `PredictHomePositionList`, and `usePredictDeposit`), and adjusts `BrowserBottomBar` tests to expect nested navigation params including `screen: 'AddBookmark'` when opening `AddBookmarkView`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a85f31b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c247eb6 commit 408ab73

15 files changed

Lines changed: 911 additions & 1707 deletions

app/components/UI/BrowserBottomBar/index.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ describe('BrowserBottomBar', () => {
391391
expect(mockNavigation.navigate).toHaveBeenCalledWith(
392392
'AddBookmarkView',
393393
expect.objectContaining({
394+
screen: 'AddBookmark',
394395
params: expect.objectContaining({
395396
title: '',
396397
}),
@@ -740,6 +741,7 @@ describe('BrowserBottomBar', () => {
740741
expect(mockNavigation.navigate).toHaveBeenCalledWith(
741742
'AddBookmarkView',
742743
expect.objectContaining({
744+
screen: 'AddBookmark',
743745
params: expect.objectContaining({
744746
title: '',
745747
}),
@@ -760,6 +762,7 @@ describe('BrowserBottomBar', () => {
760762
expect(mockNavigation.navigate).toHaveBeenCalledWith(
761763
'AddBookmarkView',
762764
expect.objectContaining({
765+
screen: 'AddBookmark',
763766
params: expect.objectContaining({
764767
url: 'custom-masked-url',
765768
}),

0 commit comments

Comments
 (0)