According to the official documentation about type checking, we have to name our navigation prop type like this:
type HomeScreenNavigationProp = StackNavigationProp<StackParamList, 'Home'>;
type HomeScreenRouteProp = RouteProp<StackParamList, 'Home'>;
interface Props {
navigation: HomeScreenNavigationProp,
route: HomeScreenRouteProp,
}
And change Home
by the each screen name.
But this can be easily simplified to this:
type Navigation = StackNavigationProp<StackParamList, 'Home'>;
type Route = RouteProp<StackParamList, 'Home'>;
interface Props {
navigation: Navigation,
route: Route,
}
Or even simpler, declaring type directly on the Props interface like this:
interface Props {
navigation: StackNavigationProp<StackParamList, 'Home'>,
route: RouteProp<StackParamList, 'Home'>,
}
With the same result.
Is there any technical reason to avoid what I am doing and name the prop types like described on the documentation?
If not, is there any convention about type naming with react-navigation and/or react-native?