[英]the component for route 'login' must be a react component
I hope all of you are doing well and good.我希望你们都做得很好。 I saw many answers related to this and implemented many answers on my code but seems like nothing worked for me.
我看到了许多与此相关的答案,并在我的代码上实现了许多答案,但似乎对我没有任何帮助。 I keep getting this annoying error.
我不断收到这个烦人的错误。 What could be the reason?
可能是什么原因? I am using react-native-router-flux for routing and expo for project.
我使用 react-native-router-flux 进行路由,使用 expo 进行项目。
Login.js登录.js
import React from "react"; import { StyleSheet, Text, View, TouchableOpacity } from "react-native"; import { Actions } from "react-native-router-flux"; import Logo from "../components/Logo"; class Login extends React.Component { signup() { Actions.signup(); } render() { return ( <View style={styles.container}> <Logo /> <form type="Login" /> <View style={styles.signupTextCont}> <Text style={styles.signupText}> You don't have an account yet?{" "} </Text> <TouchableOpacity onPress={this.signup}> <Text style={styles.signupButton}>Signup</Text> </TouchableOpacity> </View> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fbc02d", alignItems: "center", justifyContent: "center", }, signupTextCont: { flex: 1, alignItems: "flex-end", justifyContent: "center", paddingVertical: 16, flexDirection: "row", }, signupText: { color: "rgba(255,255,255,0.7)", fontSize: 16, }, signupButton: { color: "#ffffff", fontSize: 16, fontWeight: "500", }, }); export default Login;
Routes.js路由.js
import React from "react"; import { Stack, Router, Scene } from "react-native-router-flux"; import Login from "./Login"; import Signup from "./Signup"; class Routes extends React.Component { render() { return ( <Router> <Stack key="root" hideNavBar={true}> <Scene key="login" Component={Login} title="Login" /> <Scene key="signup" Component={Signup} title="Signup" /> </Stack> </Router> ); } } export default { Routes };
Please help in this regard as soon as possible because i need to submit it:(请尽快在这方面提供帮助,因为我需要提交它:(
There is a small typo in your code it's component
instead of Component
.您的代码中有一个小错字,它是
component
而不是Component
。
<Router>
<Stack key="root" hideNavBar={true}>
<Scene key="login" component={Login} title="Login" />
<Scene key="signup" component={Signup} title="Signup" />
</Stack>
</Router>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.