预期组件 class,得到 [object Object] - React-Native
Expected Component class, got [object Object] - React-Native
我在 "Expected a Component class, Got [object Object]" 上遇到过这个问题。我在 Stack 上查找了所有相关问题,我通过将我的对象大写来关注其中的大部分问题,但发生了同样的错误。一些很好的指示将不胜感激。
这是我的 App.js 文件
import React from 'react';
import { StyleSheet, AppRegistry, Text, View } from 'react-native';
import Login from "./Login";
export default class App extends React.Component {
render() {
return (
<Login />
);
}
}
和我的 Login.js 文件
import React from 'react';
import{
StyleSheet,
View,
Text,
Image,
touchableOpacity,
TextInput,
KeyboardAvoidingView
} from 'react-native';
export default class Login extends React.Component{
render(){
return(
<KeyboardAvoidingView
behavior="padding"
style={styles.container}>
<View style={styles.logoContainer}>
</View>
<View style={styles.formContainer}>
<TextInput
underlineColor="transparent"
placeholder="Email"
returnKeyType="next"
keyboardType="email-address"
onSubmitEditing={()=> this.passwordInput.focus()}
style={styles.input}/>
<TextInput
underlineColor="transparent"
placeholder="Password"
secureTextEntry
returnKeyType="go"
ref={(input) => this.passwordInput = input}
style={styles.input}/>
<touchableOpacity
style={styles.buttonContainer}>
<Text style={styles.textButton}>Login</Text>
</touchableOpacity>
</View>
</KeyboardAvoidingView>
);
}
}
它 returns 预期组件 class 的错误,得到了 [object 对象]
提前致谢。要么是我太盲目看不到自己的错误,要么是我做的完全错了。
发现了bug,我只需要将我的组件大写。 touchableOpacity
--> TouchableOpacity
感谢 Andrew Li
我在 "Expected a Component class, Got [object Object]" 上遇到过这个问题。我在 Stack 上查找了所有相关问题,我通过将我的对象大写来关注其中的大部分问题,但发生了同样的错误。一些很好的指示将不胜感激。
这是我的 App.js 文件
import React from 'react';
import { StyleSheet, AppRegistry, Text, View } from 'react-native';
import Login from "./Login";
export default class App extends React.Component {
render() {
return (
<Login />
);
}
}
和我的 Login.js 文件
import React from 'react';
import{
StyleSheet,
View,
Text,
Image,
touchableOpacity,
TextInput,
KeyboardAvoidingView
} from 'react-native';
export default class Login extends React.Component{
render(){
return(
<KeyboardAvoidingView
behavior="padding"
style={styles.container}>
<View style={styles.logoContainer}>
</View>
<View style={styles.formContainer}>
<TextInput
underlineColor="transparent"
placeholder="Email"
returnKeyType="next"
keyboardType="email-address"
onSubmitEditing={()=> this.passwordInput.focus()}
style={styles.input}/>
<TextInput
underlineColor="transparent"
placeholder="Password"
secureTextEntry
returnKeyType="go"
ref={(input) => this.passwordInput = input}
style={styles.input}/>
<touchableOpacity
style={styles.buttonContainer}>
<Text style={styles.textButton}>Login</Text>
</touchableOpacity>
</View>
</KeyboardAvoidingView>
);
}
}
它 returns 预期组件 class 的错误,得到了 [object 对象]
提前致谢。要么是我太盲目看不到自己的错误,要么是我做的完全错了。
发现了bug,我只需要将我的组件大写。 touchableOpacity
--> TouchableOpacity
感谢 Andrew Li