javascript - 无法读取未定义的属性 'routeName' - react 抽屉导航

标签 javascript reactjs react-native react-router

test 每次我将值传递给抽屉配置时,我都会收到此错误,但是当我在不传递任何配置的情况下使用它时,它工作正常。

我使用这个时出错:

const Drawer = DrawerNavigator({
 AboutUs: { screen: AboutUsScreen },
 Options: { screen: OptionsScreen },
  Home: { screen: HomeScreen }
  }, {
  initialRouteName: 'Home',
   drawerPosition: 'right',
  });

使用这个没有错误:

   const Drawer = DrawerNavigator({
   AboutUs: { screen: AboutUsScreen },
   Options: { screen: OptionsScreen },
   Home: { screen: HomeScreen }
   });

我花了几个小时试图弄明白,但没有成功。

完整代码:

import React, { Component } from 'react';
 import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';

import { Card, ListItem, Button, Icon } from 'react-native-elements'
import { DrawerNavigator } from 'react-navigation'
import HomeScreen from './Home'
import OptionsScreen from './Options'
import AboutUsScreen from './AboutUs'


const Drawer = DrawerNavigator({
AboutUs: { screen: AboutUsScreen },
Options: { screen: OptionsScreen },
Home: { screen: HomeScreen }
}, {
initialRouteName: 'Home',
drawerPosition: 'right',
});


export default Drawer ;

最佳答案

我已经添加了:

 drawerOpenRoute: 'DrawerOpen',
 drawerCloseRoute: 'DrawerClose',
 drawerToggleRoute: 'DrawerToggle'

到抽屉配置,它现在可以工作了:)

关于javascript - 无法读取未定义的属性 'routeName' - react 抽屉导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48070293/

相关文章:

javascript - 我如何将此 javascript 转换为 jquery?

javascript - 将 particles.js 展开到背景

javascript - 如何自动检查嵌套 ng-repeat 中的元素?

javascript - 如何在 react 中使用钩子(Hook)传递 this.props.children

react-native - 样式不适用于 native react 的所有 TextView

javascript - 当值被分配给组件状态时,为什么 console.log 打印以前的状态?

reactjs - Storybook 中缺少 MaterialUI 表 Prop

javascript - 样式化组件 onClick 旋转元素

javascript - JSON 中位置 0 的意外标记 <

javascript - React hooks 重置状态并获取数据