typescript - 反应导航中的道具传播
问题描述
我在打字稿中构建了一个反应本机应用程序。我正在使用来自反应导航的抽屉项目组件。
<DrawerItems
{...this.props}
items={items}
itemStyle={styles.drawerItem}
labelStyle={material.body1}
activeBackgroundColor="transparent"
/>
出于学习目的,我已经将我的 lint 设置得非常严格。现在我收到以下错误消息:
道具传播是禁止的(react/jsx-props-no-spreading)
我试图通过分开的道具,但它需要其他我不知道从哪里得到的道具。谁能告诉我如何在不传播道具的情况下重写它?
解决方案
我想通了。我调试了道具并将所有孩子单独放入。完成的代码如下所示:
<DrawerNavigatorItems
items={items}
itemStyle={styles.drawerItem}
labelStyle={material.body1Object}
activeBackgroundColor="transparent"
drawerPosition="left"
renderIcon={renderIcon}
getLabel={getLabel}
onItemPress={onItemPress}
/>
请注意,我同时也更新了我的包,所以 ...props 的原始子代可能会有所不同
推荐阅读
- postgresql - 如何从 TypeORM 连接到 Postgres Amazon-RDS?
- html - 如何使用 flexbox 获取 2 个元素以固定到窗口高度
- ios - Xcode 11 beta 中的“Preview Assets”资产目录有什么用?
- php - 创建目录 PHP / Wordpress Mkdir
- javascript - 如何通过Javascript读取(输入),打印(输出)值到文本文件?
- php - $_SERVER[“DOCUMENT_ROOT”] 为空白,但 phpinfo 显示正确的值。php7
- sql - 使用多个相似的内部查询优化选择查询
- android - 更新 AS 后使用 getContex 和 ContextCompat.checkSelfPermission() 时出错
- bash - 如何判断我的 Perl 程序是否是 shell 逻辑操作的一部分?
- java - 在文本文件中搜索多行字符串