I try to use Typescript in ReactNavigation, and got error by IDE (webstorm)
My Navigator:
export type RootStackParamList = {
AppStack: undefined;
AuthStack: undefined;
};
const RootStack = createStackNavigator<RootStackParamList>();
const Navigation: React.FunctionComponent = () => {
return (
<RootStack.Navigator>
<RootStack.Screen name="AuthStack" component={AuthStack} />
<RootStack.Screen name="AppStack" component={AppStack} />
</RootStack.Navigator>
);
}
My LoginScreen in AuthStack:
type NavigationProps = StackNavigationProp<RootStackParamList>;
const LoginScreen = () => {
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>();
const requestLogin = () => {
navigation.navigate('AppStack'); // IDE show error in 'AppStack'
}
}
I run app and everything ok, but the IDE still show error: Argument types do not match parameters.
It isn't an eslint error.
How can I fix this error?
Seems like it's a bug of old version of Webstorm. I just update Webstorm to 2023.2.5 and the error disappear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With