typescript - 类型“ConnectedComponentClass<>”不可分配给类型“ComponentType”
问题描述
因此,我在带有 typescript 和 redux 的 react-native 项目中使用 react-navigation,但是当我为抽屉导航器设置 contentComponent 道具时,我在 typescript 中收到此错误。
键入'ConnectedComponentClass<SomeClass>' is not assignable to type 'ComponentType<DrawerItemsProps>'
Type 'SomeClass' is missing the following properties from type 'DrawerItemsProps': navigation, items, getLabel, renderIcon, and 2 more.
。
是否有相同的解决方法。
对此的任何帮助将不胜感激。
解决方案
It seems that the type DrawerItemsProps
has properties like navigation, items, getLabel, renderIcon
and more and these are missing in your SomeClass
interface.
So you can make all these properties which are missing as optional using '?' like below
interface DrawerItemsProps {
// other properties
navigation?: yourType,
items?: yourType,
getLabel?: yourType,
renderIcon?: yourType
}
推荐阅读
- wpf - 为基本 WPF 选择正确的 .Net Framework - 无法安装 NUGET 包
- sql - Postgresql:序列扫描而不是索引扫描
- scala - 从 scala (sangria) 中的外部 .graphqls 文件生成 GraphQL 模式
- laravel - 如何从 Laravel 应用程序的 Vue 组件中写入 Laravel 日志?
- sql - 我可以在表中的多个列上引用单个外键吗?如果是,如何在实体框架核心中配置它
- javascript - NextJs 多区域共享标头
- sql - 如何使用 where 子句获取和统一特定数量并在一张表中进行 3 次
- python - 如何保持日期时间索引?ValueWarning:提供了不受支持的索引,在预测时将被忽略
- react-admin - 大写和小写字符串列的排序混合 - React-Admin
- linux - 多个桌面在 bspwm 中不工作 | bspwmrc 没有被读取?