Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获错误:undefined不是对象(计算';Y.props.navigation';)touchableHandlePress@[本机代码]_Javascript_React Native_React Navigation_Expo_React Navigation Drawer - Fatal编程技术网

Javascript 未捕获错误:undefined不是对象(计算';Y.props.navigation';)touchableHandlePress@[本机代码]

Javascript 未捕获错误:undefined不是对象(计算';Y.props.navigation';)touchableHandlePress@[本机代码],javascript,react-native,react-navigation,expo,react-navigation-drawer,Javascript,React Native,React Navigation,Expo,React Navigation Drawer,我在react导航标题中添加了一个抽屉菜单按钮来打开抽屉菜单 图标正常显示,但按下时返回引用的错误 import React from 'react'; import { View, Dimensions } from 'react-native'; import { Button, Icon } from 'native-base'; import { createAppContainer, createStackNavigator, createDrawerNavigator } from

我在react导航标题中添加了一个抽屉菜单按钮来打开抽屉菜单

图标正常显示,但按下时返回引用的错误

import React from 'react';
import { View, Dimensions } from 'react-native';
import { Button, Icon } from 'native-base';
import { createAppContainer, createStackNavigator, createDrawerNavigator } from 'react-navigation';
...

const DrawerConfig = {
  drawerWidth: Dimensions.get('window').width * 0.75,
  contentComponent: ({ navigation }) => {
    return(<MenuDrawer navigation={navigation} />)
  }
}

const HomeNavigator = createStackNavigator ({
...
}, {
  defaultNavigationOptions: ({ navigation }) => {
    return {
      headerTitleStyle: {
        fontWeight: 'bold'
      },
      headerLeft: (
        <Button transparent onPress={() => this.props.navigation.toggleDrawer()}>
          <Icon name='menu' style={{color: '#FFF'}} />
        </Button>
      ),
      headerRight: (
        <HomeIcon navigation={navigation} />
      ),
      headerStyle: {
        backgroundColor: '#b80003'
      },
      headerTintColor: '#FFF'
    }
  }
});

const DrawerNavigator = createDrawerNavigator (
  {
    'Principal': {
      screen: HomeNavigator
    },
    'Sobre o Aplicativo': {
      screen: InformationApp
    },
    'Sobre os Responsáveis': {
      screen: Team
    },
    'Sobre o Projeto': {
      screen: Project
    },
    'Política e Termos': {
      screen: Policy
    }
  },
  DrawerConfig
);

const AppDrawerContainer = createAppContainer(DrawerNavigator);

export default AppDrawerContainer;
从“React”导入React;
从“react native”导入{View,Dimensions};
从“本机基”导入{按钮,图标};
从“react navigation”导入{createAppContainer、createStackNavigator、createDrawerNavigator};
...
常数抽屉配置={
抽屉宽度:尺寸。获取(“窗口”)。宽度*0.75,
contentComponent:({navigation})=>{
返回()
}
}
常量HomeNavigator=createStackNavigator({
...
}, {
defaultNavigationOptions:({navigation})=>{
返回{
头饰样式:{
fontWeight:“粗体”
},
左校长:(
this.props.navigation.toggleDrawer()}>
),
头灯:(
),
头型:{
背景颜色:“#b80003”
},
标题颜色:“#FFF”
}
}
});
const pawernavigator=createpawernavigator(
{
“校长”:{
屏幕:HomeNavigator
},
“Sobre o Aplicativo”:{
屏幕:InformationApp
},
“Sobre os responseáveis”:{
屏幕:团队
},
“Sobre o Projeto”:{
屏幕:项目
},
“Política e Termos”:{
屏幕:策略
}
},
付款人配置
);
const AppDroperContainer=createAppContainer(抽屉驱动程序);
导出默认AppDroperContainer;

需要注意的是,对于属于
const DrawerNavigator=createDrawerNavigator
的屏幕,我正在使用上面相同的代码渲染drawermenu按钮,并且该按钮工作正常,只有在
const screens HomeNavigator=createStackNavigator
这样更改代码时才会出现错误

onPress={() => navigation.toggleDrawer()}>