[英]route (react-navigation) type in typescript
For navigations, I am using useNavigation from '@react-navigation/native';
对于导航,我使用
useNavigation from '@react-navigation/native';
I am using this to pass data between two screens in my app:我正在使用它在我的应用程序的两个屏幕之间传递数据:
type UserDetailsProps = {
onDeleteContact: (id: number) => void;
route: any;
};
I don't want to use the any
time but I don't know what other type is suitable here.我不想在
any
时候使用,但我不知道这里适合什么其他类型。
You can use this type:您可以使用这种类型:
type RouteParams = {
firstName?: string;
}
route?: RouteProp<Record<string, RouteParams>, ''>;
Notice that RouteProp is a named export of @react-navigation/native
请注意,RouteProp 是
@react-navigation/native
的命名导出
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.