refactor: remove ScreenComponent any cast from staking routes#28108
Conversation
|
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. |
The staking routes used `type ScreenComponent = React.ComponentType<any>` with eslint-disable to work around React Navigation type mismatches. Migrates affected components to use the useRoute() hook with properly typed generics instead of receiving route as a prop. Changes: - StakeConfirmationView: switched to useRoute() hook - UnstakeConfirmationView: switched to useRoute() hook - GasImpactModal: switched to useRoute() hook - Type files: exported RouteParams interfaces, removed dead Props types - Tests: updated to mock useRoute() instead of passing route as prop Made-with: Cursor
520ef13 to
5677adb
Compare
|
Thank you! |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: This is a low-risk change since:
The existing E2E stake test ( SmokeConfirmations is not selected because the staking confirmation views are specialized stake-specific screens, not the general transaction confirmation system tested by SmokeConfirmations. The stake flow is specifically covered under SmokeTrade. Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
|



Description
The staking routes used
type ScreenComponent = React.ComponentType<any>with// eslint-disable-next-line @typescript-eslint/no-explicit-anyto work around React Navigation type mismatches when screen components accepted route props directly. This PR removes that escape hatch by migrating the affected components to use theuseRoute()hook with properly typed generics instead of receivingrouteas a prop.Changes:
routes/index.tsx: Removed theScreenComponenttype alias and allas ScreenComponentcastsStakeConfirmationView: Switched from({ route }: StakeConfirmationViewProps)touseRoute<RouteProp<...>>()hookUnstakeConfirmationView: Same migration touseRoute()hookGasImpactModal: Same migration touseRoute()hookRouteParamsinterfaces for use byuseRoute()callers; removed deadStakeConfirmationViewPropsandGasImpactModalPropsinterfaces (keptUnstakeConfirmationViewPropsas it's still used by the confirmations module)useRoute()instead of passing route as a component propChangelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
N/A — this is a pure refactoring with no user-facing behavior change. Existing unit tests (3 suites, 11 tests) cover the affected components.
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Made with Cursor
Note
Low Risk
Low risk refactor limited to React Navigation wiring and TypeScript types; main risk is runtime issues if any of these components are rendered without the expected route params.
Overview
Refactors
StakeConfirmationView,UnstakeConfirmationView, andGasImpactModalto stop acceptingrouteprops and instead fetch strongly-typed route params viauseRoute<RouteProp<...>>(), reducing the need forany-style screen component casts.Updates associated
*.types.tsto exportRouteParamstypes (and removes now-unused props types where applicable), and adjusts unit tests to mockuseRoute()rather than passingrouteprops into the components.Written by Cursor Bugbot for commit 550a9d6. This will update automatically on new commits. Configure here.