React Native 项目返回“TypeError:undefined 不是对象”
2020-05-18
3129
我正在开发一个 React Native 项目,出现了这个错误
04381​​3401
我该如何解决这个错误?
这是 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"
}
}
2个回答
您需要在
react-native
中导入
Animated
,如下所示
import {View, TextInput, Animated, Text, StyleSheet} from 'react-native';
Mehul Kabaria
2020-05-18
您的问题与 这个 类似。
希望对您有所帮助
Hossein Arsheia
2020-05-18