I have a stack navigator with a screen component:
const Stack = createStackNavigator<StackParamList>(); // StackParamList is custom typefunction Navigator() { return (<Stack.Navigator initialRouteName="comp"><Stack.Screen name="comp" component={Component} /></Stack.Navigator> );}
By default react-navigation
pass props route
and navigation
to the screen component and to use these, the component must be defined like below as mentioned in official documentation:
export default function Component({route, navigation}){ // User `route` and `navigation` however you like it}
My IDE also prompts me to provide types for props something like:
export default function Component({route: RouteType, navigation: NavigationType})
Easiest way to do this is to specify RouteType
and NavigationType
as any
but I would rather avoid it to get most out of static type checking. So, what is the best way to receive these route
and navigation
props? What exactly should be in RouteType
and NavigationType
excluding any
?