未捕获的错误:不断违反:元素类型无效:预期为字符串(对于内置组件)或类/函数,但得到:未定义

时间:2019-02-22 12:47:19

标签: javascript react-native ecmascript-6

我正在使用react-navigation创建一个DrawerNavigation。在我决定将其拆分为较小的模块之前,一切都在一个文件中运行良好。 该结构是基本的Drawer Navigator,其中包含两个Stack Navigator。

DrawerNavigators.js
StackNavigators
        |__HomeNavigator.js
        |__MenuNavigator.js

我花了数小时试图调查问题,起初该错误似乎与模块未正确导入有关,但现在我认为导入是正确的,但是尝试导航后仍然会收到错误到特定屏幕。

这是我的代码示例:

  

DrawerNavigator.js

import React, { Component } from 'react';
import { View, Platform, Image, StyleSheet, ScrollView, Text } from 'react-native';
import { Icon } from 'react-native-elements';
import HomeNavigator from './StackNavigators/HomeNavigator';
import {   
    createStackNavigator, 
    createAppContainer, 
    createDrawerNavigator,
        } from 'react-navigation';

const MainNavigator = createDrawerNavigator({
    Acceuil: {
        screen: HomeNavigator,
        navigationOptions: {
            title: 'Acceuil',
            drawerLabel: 'Acceuil',
            drawerIcon: ({ tintColor }) => (
                <Icon 
                    name='home'
                    type='font-awesome'
                    size={24}
                    color={tintColor}
                    />
            )
        }
    },
});

export default createAppContainer(MainNavigator);
  

HomeNavigator.js

import {Icon} from 'react-native-elements';
import HomeScreen from '../../HomeComponent';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import React, { Component } from 'react';


const HomeNavigator = createStackNavigator({
    Home: { screen: HomeScreen }
    },
    {
        navigationOptions: {
            headerStyle: {
                backgroundColor: "#512DA8"
            },
            headerTintColor: '#fff',
            headerTitleStyle: {
                color: "#fff"            
            },
        }
    }
);

export default HomeNavigator;

以下是该错误的屏幕截图。任何帮助将不胜感激。

enter image description here

0 个答案:

没有答案