Navigation.navigate() with an auto-completable type #11901
Dohun-choi
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
You'll get autocompletion and type checking for |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When passing a screen name as an argument to Navigation.navigate(), users can navigate to the corresponding screen. With the following implementation, type errors are avoided, and developers can utilize autocomplete for the screen names they've defined.
I referred to @react-navigation/routers/src/type.ts, line 97:
export type ParamListBase = Record<string, object | undefined>;
type Navigation = NativeStackNavigationProp<
// Modifying ParamListBase
Record<keyof NativeStackParamList, object | undefined>
When using navigate in components, developers can utilize autocomplete for registered screens, facilitating easier code writing. For example, when using useNavigation("screenName"), screen names can be auto-completed.
If such a feature already exists, please disregard my suggestion. It would be better if you could inform me of that method.
I used a translation tool, so the sentence may sound awkward.
Beta Was this translation helpful? Give feedback.
All reactions