【问题标题】:Cannot read property 'routeName' of undefined - react navigation drawer无法读取未定义的属性“routeName”-反应导航抽屉
【发布时间】:2018-01-03 02:10:56
【问题描述】:

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

我使用这个会出错:

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 ;

【问题讨论】:

    标签: javascript reactjs react-native react-router


    【解决方案1】:

    我已添加:

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

    到抽屉配置,它现在正在工作:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-30
      • 2019-01-11
      • 1970-01-01
      • 2019-12-05
      • 1970-01-01
      相关资源
      最近更新 更多