I have a model of these:
image: string;
redirect_option: 'PROFILE' | 'PRODUCT';
redirect: Product | User;
Now I render the list and want add a function:
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>
);
Now I get this error:
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,
I know the problem but IDK how can I solve it. this comes at navigation...params
CodePudding user response:
If you're just looking for a syntax fix:
navigation.navigate('UserProfile', params as CurrentUser);
But yeah, the real problem might has something to do with the way you're structuring and typing your codes.