react-native - 类型 IntrinsicClassAttributes 上不存在属性
问题描述
我必须承认这是我在 ReactNative 世界中的第一步。
我尝试升级所有 npm 库,如果我运行 build 命令,我会遇到很多错误,例如:
Property 'underlayColor' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps> & Readonly<{ children?: ReactNode; }>'.
Property 'backgroundColor' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps> & Readonly<{ children?: ReactNode; }>'.
Property 'textStyle' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps> & Readonly<{ children?: ReactNode; }>'.
等等
这很奇怪,因为我做了快速研究,上面的属性可用于 element. 我的问题是:我应该添加额外的库或构建元素吗?或者也许在最新版本的 react native 中,Button 组件的属性真的被禁用了?
编辑 我的代码的示例部分:错误是关于缺少 underlayColor
<View style={[styles.modal.footer]}>
<Button
buttonStyle={styles.common.buttonTransparent}
onPress={() => requestAnimationFrame(() => this.setState({isModalVisible: false}))}
title={I18n.t('CANCEL')}
underlayColor={styles.palette.transparent}
textStyle={styles.modal.actionButtonText}
containerViewStyle={styles.modal.actionButtonContainer}
/>
<Button
buttonStyle={styles.common.buttonTransparent}
onPress={this.createReport}
title={I18n.t('CREATE')}
underlayColor={styles.palette.transparent}
textStyle={styles.modal.actionButtonText}
containerViewStyle={styles.modal.actionButtonContainer}
/>
</View>
解决方案
错误表明textStyle
并且underlayColor
不是您的组件的有效道具Button
。好像您从某个库中导入了按钮。仔细检查您的图书馆文档。
另外,请检查您的样式,它应该包含backgroundColor
无效的样式。
推荐阅读
- java - 查找字符串的指数
- excel-formula - Excel CountIfs 多个条件与范围或条件与单元格引用
- excel - 使用 if then 语句键入不匹配错误
- android - Android默认键盘的自定义键
- node.js - 是否有用于 MongoDB 的稳定数据迁移工具用于 Nodejs 应用程序?
- php - 不回显时数组到字符串的转换
- google-chrome-devtools - Google Chrome 代码覆盖率 - 删除未使用的代码
- javascript - 从 Ember 2.16 组件集成测试模拟操作返回承诺
- firebase - Firebase 是全局安装的,我想为不同的项目使用不同的谷歌帐户,但无法
- python - 在 contains 方法中使用完全匹配的正则表达式