react-native - React Native 项目返回“TypeError: undefined is not an object”
问题描述
我正在开发一个 React Native 项目,我收到了这个错误
TypeError:未定义不是对象(评估'_reactNative.Animated.Text.propTypes.style')
我该如何解决这个错误?
这是 App.js
import React from 'react';
import {View, TextInput, Text, StyleSheet} from 'react-native';
import {TextField} from 'react-native-material-textfield';
const App = () => {
return (
<View style={styles.container}>
<Text style={styles.heading}>Billing Information</Text>
<Text style={styles.paragraph}>Name</Text>
<TextInput style={styles.input} placeholder="Mark" />
<TextField label="Email" />
</View>
);
};
const styles = StyleSheet.create({
container: {
marginTop: 50,
padding: 20,
color: '#ff0000',
},
heading: {
fontSize: 18,
fontWeight: 'bold',
textAlign: 'left',
color: '#ff0000',
},
paragraph: {
fontSize: 18,
fontWeight: 'bold',
textAlign: 'left',
color: '#0000ff',
backgroundColor: '#32CD32',
},
input: {
fontSize: 18,
fontWeight: 'bold',
textAlign: 'left',
color: '#0000ff',
},
});
export default App;
`````````
This is package.json
```````
{
"name": "form",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-elements": "^2.0.0",
"react-native-form-builder": "^1.0.16",
"react-native-material-textfield": "^0.16.1"
},
"devDependencies": {
"@babel/core": "7.9.6",
"@babel/runtime": "7.9.6",
"@react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "6.8.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.58.0",
"react-test-renderer": "16.11.0"
},
"jest": {
"preset": "react-native"
}
}
解决方案
你需要Animated
像react-native
下面这样导入
import {View, TextInput, Animated, Text, StyleSheet} from 'react-native';
推荐阅读
- angular - Why we use @Injectable({ providedIn: 'root' }) to reach class?
- reactjs - material-ui 小吃吧改变颜色而不为每种颜色制作新的?
- pytorch - PyTorch 的输入类型(torch.FloatTensor)和权重类型(torch.cuda.FloatTensor)应该是一样的但是我的数据已经推送到GPU
- python - 如何遍历一个元素并使用 .split() 元素从显示的列表中删除冒号?
- reactjs - 如何使用react-spring顺序执行两个动画?
- python - 从列中的相似值创建嵌套字典并使用值作为字典的键包含具有该值的所有行
- for-loop - WS2812B的第一个led在代码进入for循环时开始点亮
- java - Resttemplate JUNIT Exchange方法无法解决
- python - Python 如何在没有 linter 的情况下迭代 StrEnum(PyCharm 检查)未解析的引用
- java - findViewById 在 activity_main 中找不到 RecyclerView