Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 未捕获不变冲突:元素类型无效_Reactjs_React Native - Fatal编程技术网

Reactjs 未捕获不变冲突:元素类型无效

Reactjs 未捕获不变冲突:元素类型无效,reactjs,react-native,Reactjs,React Native,我只是在摆弄react native,试图用一个简单的导航构建一个模型。然而,我被困在一个点上,我不知道造成这种情况的原因 index.js import { AppRegistry } from 'react-native'; import App from './App'; AppRegistry.registerComponent('AwesomeProject', () => App); App.js import React, { Component } from 'react

我只是在摆弄react native,试图用一个简单的导航构建一个模型。然而,我被困在一个点上,我不知道造成这种情况的原因

index.js

import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('AwesomeProject', () => App);
App.js

import React, { Component } from 'react'
import { AppRegistry, View, Text, StyleSheet } from 'react-native'
import Routes from './src/config/routes';

export class App extends Component {
  render() {
    return (
      <View>
        <Routes/>
      </View>
    )
  }
}
错误:


我不确定这是否有用。但请尝试按以下方式进行检查:

  • 请更正App.js上的文件名,如下所示:
    从“/src/config/Routes”导入路由
    与上面的代码一样,文件名应该是Routes,而不是Routes
  • 在Routes.js上,请尝试执行以下操作:
    
    导出默认常量路由=StackNavigator({
    initialRouteName:Home,
    主页:{screen:Home},
    注册:{屏幕:注册},
    },
    {
    headerMode:“无”,
    });
    

  • 正如“意外令牌”错误所表明的,您的
    routes.js
    中存在语法错误。您还没有将列表用方括号括起来。@JoeClay我已经在app.js中包含了路线。我仍然得到了第一个错误。有什么帮助吗?这没用。
    import React from "react";
    import { Platform } from "react-native";
    import { StackNavigator } from "react-navigation";
    
    import Home from '../screens/Home';
    import SignUp from '../screens/SignUp';
    
    export default const Routes = StackNavigator(
        {
            Home: { screen: Home },
            SignUp: { screen: SignUp },
        },
        {
            initialRouteName: "Home",
            headerMode: "none",
        }
    );