未捕获的不变违规:元素类型无效

时间:2017-12-07 14:02:15

标签: 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'
import { AppRegistry, View, Text, StyleSheet } from 'react-native'
import Routes from './src/config/routes';

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

Routes.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",
    }
);

错误:

https://bugs.chromium.org/p/chromium/issues/detail?id=721138

1 个答案:

答案 0 :(得分:0)

我不确定这是否有用。但请尝试检查如下:

  1. 请在App.js上更正文件名,如下所示: import Routes from './src/config/Routes'; 如上面的代码,您的文件名应该是路由,而不是路由。
  2. 在Routes.js上,请尝试执行以下操作: export default const Routes = StackNavigator({ initialRouteName: Home, Home: { screen: Home }, SignUp: { screen: SignUp }, }, { headerMode: "none", });