![](/img/trans.png)
[英]undefined is not an object (evaluating '_reactNative.Animated.Text.propTypes.style')
[英]TypeError: undefined is not an object (evaluating '_reactNative.Animated.Text.propTypes.style')
我解决了这个问题,
评论itemTextStyle: Text.propTypes.style
in
..\node_modules\react-native-material-dropdown\src\components\dropdown
文件。
并删除Animated
中的Animated.Text.propTypes.style
词缀/索引
助手/索引
标签/索引
react-native-material-textfield
。
并添加了import { Animated, Text} from 'react-native';
在上述三个文件中的每一个中。
这是我找到的另一个解决方案。
删除已安装的 package react-native-material-dropdown
yarn remove react-native-material-dropdown
安装新包react-native-material-dropdown-v2
和react-native-paper
yarn add react-native-material-dropdown-v2 react-native-paper
在代码中将 react react-native-material-dropdown
交换为react-native-material-dropdown-v2
例如import { Dropdown } from 'react-native-material-dropdown'
到import { Dropdown } from 'react-native-material-dropdown-v2'
我在使用@react-navigation/drawer 时发现了同样的问题
我已经通过这些步骤解决了它。
node_modules
然后搜索react-native-material-textfield
打开文件和 go 到src
文件夹src
下你会看到affix
, helper
, label
文件夹 - 每个文件夹下都有一个index.js
index.js
一个一个打开(所有 3 个文件夹)并搜索文本style: Animated.Text.propTypes.style
,并将其替换为style: Text.propTypes
import { Animated, Text} from 'react-native';
github 上有一个关于这个问题的问题。 正如评论中提到的,可以使用此选项来编辑节点模块,或创建补丁,这样每次添加新库或运行 npm 安装时都无需编辑文件。
操作说明:
修复已应用。 在 package.json 中添加以下内容,下次不再重复:
"scripts": {
+ "postinstall": "patch-package"
}
https://github.com/n4kz/react-native-material-textfield/issues/249#issuecomment-625791243
我在使用 react-native-material-dropdown 时遇到了同样的问题。
使固定:
node_modules/react-native-material-textfield/src/components
affix/index.js
、 helper/index.js
和label/index.js
style: Animated.Text.propTypes.style
替换为style: Text.propType
import { Animated,Text} from 'react-native'
这应该可以解决问题
react-native 版本:0.64.0
只需更新他们用修复更新他们的库的库是链接https://www.npmjs.com/package/react-native-material-dropdown-v2-fixed
我使用react-native-material-textfield
。 导入前添加我的js文件:
import { Animated, Text } from 'react-native';
Animated.Text.propTypes = Animated.Text.propTypes || Text.propTypes;
import { TextField } from 'react-native-material-textfield';
我已经通过使用这个库解决了我的问题
react-native-material-dropdown-no-proptypes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.