简体   繁体   English

路由“登录”的组件必须是反应组件

[英]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.

相关问题 路由组件必须是React组件 - The component for route must be a React component route 的组件必须是 react native 中的 react 组件 - The component for route must be a react component in react native 反应本机导航-路线的组件必须由react组件 - React native navigation - the component for the route must by react component 路由组件必须是 React Native Expo 中的 React 组件错误 - The Component for route must be a react component error in React native expo React Native-堆栈导航和TabNavigation(用于路由的组件必须是React组件) - React Native - Stack Navigation and TabNavigation ( The component for route must be a React component ) 反应私有路由不渲染登录组件 - React private route not renderring the Login component 错误:[div] 不是<route>零件。 的所有子组件<routes>必须是<route>或者<react.fragment></react.fragment></route></routes></route> - Error: [div] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment> 未捕获的错误:[PrivateRoute] 不是<route>零件。 的所有子组件<routes>必须是<route>或者<react.fragment></react.fragment></route></routes></route> - Uncaught Error: [PrivateRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment> 错误:[主页] 不是<Route>成分。 的所有子组件<Routes>必须是<Route>或者<React.Fragment> - Error: [Home] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment> BrowserRouter 不是一个<Route>零件。 的所有子组件<Routes>必须是<Route>或者<React.Fragment> - BrowserRouter is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM