当我在虚拟设备上运行android应用时,它会引发错误Undefined is not a function
我尝试在代码中将“ AppDrawerNavigator”替换为“ App”,它解决了该问题,但是在控制台中创建了另一个“重复声明“ App””错误。这是我的代码:
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import { DrawerNavigator } from 'react-navigation';
import HomeScreen from './screens/HomeScreen';
export default class App extends Component {
render() {
return (
<AppNavigationDrawer />
);
}
}
const AppNavigationDrawer = DrawerNavigator({
Home: {screen: HomeScreen},
});
错误
未定义不是函数(评估'(0,_reactNavigation.DrawerNavigator)({主页:{screen:_HomeScreen2.default}, });)
答案 0 :(得分:3)
DrawerNavigator
似乎不在react-navigation@latest
相反,将其导入为createDrawerNavigator
import { createDrawerNavigator } from 'react-navigation';