Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6212

react-navigation 5.x: TS2345: Argument of type ' ... ' is not assignable to parameter of type '... '

$
0
0

I have migrated from react-navigation 4.x to 5.x. Since I am using typescript, I am trying to add the types. I should mention that the functionality works perfectly fine. However, I am getting this typescript error:

enter image description here

TS2345: Argument of type '["PaperPlaneDetails", { paperPlane: PaperPlaneInterface; returnRoute: string; }]' is not assignable to parameter of type '["PaperPlaneDetails"] | ["PaperPlaneDetails", undefined]'.   Type '["PaperPlaneDetails", { paperPlane: PaperPlaneInterface; returnRoute: string; }]' is not assignable to type '["PaperPlaneDetails", undefined]'.     Type '{ paperPlane: PaperPlaneInterface; returnRoute: string; }' is not assignable to type 'undefined'.
//OpenPaperPlaneModal.tsx located in ReceivePaperPlaneScreen.tsxtype AppStackParamList = {  EditProfile: undefined;  Introduction: undefined;  PaperPlaneDetails: undefined;  Logout: undefined;  DebugScreen: undefined;  PaperPlane: undefined;  MyProfileScreen: undefined;  FollowersScreen: undefined;  FollowingScreen: undefined;  UsersProfileScreen: undefined;  SettingsScreen: undefined;  CommentsScreen: undefined;};type PaperPlaneBottomTabNavigatorParamList = {  TakePaperPlaneScreen: undefined;  ReceivePaperPlaneScreen: undefined;  NotificationScreen: undefined;};type OpenPaperPlaneModalNavigationProp = CompositeNavigationProp<  BottomTabNavigationProp<    PaperPlaneBottomTabNavigatorParamList,'ReceivePaperPlaneScreen'>,  StackNavigationProp<AppStackParamList>>;export default function OpenPaperPlaneModal(props) {  const navigation = useNavigation<OpenPaperPlaneModalNavigationProp>();  navigation.navigate('PaperPlaneDetails', {    paperPlane: props.paperPlane,    returnRoute: 'ReceivePaperPlaneScreen',  });}
"typescript": '3.8.3'"@react-navigation/bottom-tabs": "^5.3.1","@react-navigation/native": "^5.2.1","@react-navigation/stack": "^5.2.16",

Viewing all articles
Browse latest Browse all 6212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>