MetaMask / MetaMask/metamask-mobile
[NAV UPGRADE - 3] Replace `useRoute` and `useParams` with `route` from component props so that params are derived from root param list
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
### What is this about?
`useRoute` and `useParams` does not pick up on the globally defined navigation types. As a result, the navigation param types can be missed while using these hooks. For better type safety, two changes can be made for each component:
- A component's prop type definition should use `StackScreenProps` and reference root param list along with its associated screen name. Ex. `type ComponentProp = StackScreenProps`
- Instead of deriving params from `useRoute` or `useParams`, access `route.params` from props
### Scenario
_No response_
### Design
_No response_
### Technical Details
- A component's prop type definition should use `StackScreenProps` and reference root param list along with its associated screen name. Ex. `type ComponentProp = StackScreenProps`
- Instead of deriving params from `useRoute` or `useParams`, access `route.params` from props
- Components being updated will need an associated entry in the root params list, which is used as reference in generic types
### Threat Modeling Framework
_No response_
### Acceptance Criteria
- Components updated using `StackScreenProps` and `route.params` should have proper type safety on available route param properties
### Stakeholder review needed before the work gets merged
- [ ] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [ ] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)
### References
- Draft PR from @Cal-L - https://github.com/MetaMask/metamask-mobile/commit/593ec0d223e665408a7590bc41fc60a49ee9e587#diff-d51192e4f4a311924c07e8729744176b6d6664bca6ae7ceef5494953df13de95R268
Contributor guide
Assessment
This issue has not been assessed yet.