I am using react-navigation 5.5.1
, all is working great but I have some trouble with typescript.
I tried to type the navigation
prop according to the docs (https://reactnavigation.org/docs/typescript/) but it looks like navigation is still type any
.
Any clues what I missed?
export type AppParamList = { Intro: undefined; Stories: undefined;};interface RoutesProps {}const Stack = createStackNavigator<AppParamList>();const Routes: FC<RoutesProps> = () => { return (<SafeAreaProvider><NavigationContainer><Stack.Navigator><Stack.Screen name="Intro" component={Intro} /><Stack.Screen name="Stories" component={Stories} /></Stack.Navigator></NavigationContainer></SafeAreaProvider> );};// Intro.tsximport { StackNavigationProp } from '@react-navigation/stack';import { AppParamList } from ../type IntroScreenNavigationProp = StackNavigationProp<AppParamList, 'Intro'>;type Props = { navigation: IntroScreenNavigationProp;};const Intro = ({ navigation }: Props): ReactElement => (<SafeAreaView><Text>Intro</Text><TouchableHighlight onPress={() => navigation.navigate('Stories')}><Text>Go to stories</Text></TouchableHighlight></SafeAreaView>);