我有一個模型:
image: string;
redirect_option: 'PROFILE' | 'PRODUCT';
redirect: Product | User;
現在我渲染串列并想要添加一個函式:
const handleNavigateToRedirectedOption = ({ redirected_option, params }: { redirected_option: 'PROFILE' | 'PRODUCT'; redirect: Product | User;}) => {
redirected_option === 'PROFILE' && navigation.navigate('UserProfile', params);
};
const renderItem = ({ item }) => (
<Pressable onPress={}>
<Text>List</Text>
</Pressable>
);
現在我得到這個錯誤:
Argument of type 'IProduct | CurrentUser' is not assignable to parameter of type 'CurrentUser'.
Type 'IProduct' is missing the following properties from type 'CurrentUser': user_id, profile_image,
我知道這個問題,但 IDK 我該如何解決它。這來自導航...引數
uj5u.com熱心網友回復:
如果您只是在尋找語法修復:
navigation.navigate('UserProfile', params as CurrentUser);
但是,是的,真正的問題可能與您構建和鍵入代碼的方式有關。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/485596.html
標籤:javascript 反应 打字稿 反应式 世博会
上一篇:獲取異步迭代的第一個元素
下一篇:使用node.js上傳影像檔案
