gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 13:56:16 28 4
gpt4 key购买 nike

我已经从 react-navigation 迁移过来了4.x 5.x .因为我正在使用 typescript ,我正在尝试添加类型。我应该提到该功能运行良好。但是,我收到此 typescript 错误:

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.tsx

type 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",

最佳答案

@kasra 我能够解决我的问题。确保在路由和 paramList 中没有任何同名的屏幕。

关于reactjs - react 导航 5.x : TS2345: Argument of type ' ... ' is not assignable to parameter of type '... ' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61849601/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com