DrawerNavigator-未定义是一个函数

时间:2018-12-24 21:28:52

标签: javascript react-native react-native-android

当我在虚拟设备上运行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},     });)

1 个答案:

答案 0 :(得分:3)

DrawerNavigator似乎不在react-navigation@latest

的主要出口file中的命名出口

相反,将其导入为createDrawerNavigator

import { createDrawerNavigator } from 'react-navigation';