也将其放置在github上:https://github.com/react-navigation/react-navigation/issues/6433#issue-517008038
当前反应本机版本正在运行;
"react-native": "0.61.2"
尝试在android模拟器上运行项目时出现此错误; (无法发布照片。...)
元素类型无效,应该是内置组件或类/函数的字符串,但是未定义,您可能忘记了从定义的文件中导出组件,或者可能混淆了默认导入和命名导入
这是我的主要代码文件;
import React from 'react';
import {View, TouchableOpacity} from 'react-native';
import {createAppContainer} from 'react-navigation';
import {createDrawerNavigator} from 'react-navigation-drawer';
import {createStackNavigator} from 'react-navigation-stack';
import HomeScreen from './screens/HomeScreen';
import LoginScreen from './screens/LoginScreen';
import SettingsScreen from './screens/SettingsScreen';
import FontAwesomeIcon from '@fortawesome/fontawesome-svg-core';
const NavigationDrawerStructure = props => {
const toggleDrawer = () => {
props.navigationProps.toggleDrawer();
};
return (
<View style={{flexDirection: 'row'}}>
<TouchableOpacity onPress={toggleDrawer.bind()}>
<FontAwesomeIcon
icon="bars"
style={{width: 25, height: 25, marginLeft: 5}}
/>
</TouchableOpacity>
</View>
);
};
const FirstActivity_StackNavigator = createStackNavigator({
First: {
screen: HomeScreen,
navigationOptions: ({navigation}) => ({
title: 'Home Screen',
headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
headerStyle: {
backgroundColor: '#29aae0',
},
headerTintColor: '#fff',
}),
},
});
const LoginScreen_StackNavigator = createStackNavigator({
Second: {
screen: LoginScreen,
navigationOptions: ({navigation}) => ({
title: 'Login Screen',
headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
headerStyle: {
backgroundColor: '#29aae0',
},
headerTintColor: '#fff',
}),
},
});
const SettingsScreen_StackNavigator = createStackNavigator({
Third: {
screen: SettingsScreen,
navigationOptions: ({navigation}) => ({
title: 'Settings Screen',
headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
headerStyle: {
backgroundColor: '#29aae0',
},
headerTintColor: '#fff',
}),
},
});
const DrawerNavigatorExample = createDrawerNavigator({
HomeScreen: {
screen: FirstActivity_StackNavigator,
navigationOptions: {
drawerLabel: 'Home Screen',
},
},
LoginScreen: {
screen: LoginScreen_StackNavigator,
navigationOptions: {
drawerLabel: 'Login Screen',
},
},
SettingsScreen: {
screen: SettingsScreen_StackNavigator,
navigationOptions: {
drawerLabel: 'Settings Screen',
},
},
});
导出默认的createAppContainer(DrawerNavigatorExample);
该错误表明NavigationDrawerStructure必须是一个函数;
const NavigationDrawerStructure = props => {
还是没有出口;
在同一文件中构造并使用(之前没有错误)
有人可以帮忙吗?