未定义不是对象(评估为'(0 _reactnavigation.DrawerNavigator)')

时间:2019-09-04 07:04:26

标签: react-native react-navigation react-navigation-drawer

我创建了自定义边栏,并有5到6个屏幕。我正在使用NativeBase,并希望使用DrawerNavigator选项打开补充工具栏,但是当我应用以下代码时,出现了问题。

抽屉导航器代码

 <div class="container">
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
    </div>

 

2 个答案:

答案 0 :(得分:0)

此处的错误是您使用的是DrawerNavigation而不是createDrawerNavigator

只要做那些改变,你就应该好

import { createDrawerNavigator } from "react-navigation";

...

const SidebarNavigator = createDrawerNavigator( ... )

来源:https://reactnavigation.org/docs/en/drawer-navigator.html

答案 1 :(得分:0)

您可以尝试使用此代码

您可以使用createDrawerNavigatorcreateAppContainer

import { createDrawerNavigator, createAppContainer } from "react-navigation";

...

const SidebarNavigator = createDrawerNavigator( ... )

const AppContainer = createAppContainer(SidebarNavigator);

// Now AppContainer is the main component for React to render

export default AppContainer;