TABBARONPRESS在React Nakitage中无法使用React导航选项卡



我正在使用嵌套导航抽屉> TAB>堆栈导航器。

导航器正在工作,但是当我点击选项卡项目时,它会抛出以下错误

未定义不是对象(评估'_ref4.route') _getOnpress tabview.js:110:44 _handleonpress tabbartop.js:127:31 OnPress tabbar.js:466:33 _CALLTIMER JSTIMERS.JS:156:15 Calltimers Jstimers.js:411:17 __ callfunction MessageQueue.js:302:47 MessageQueue.js:116:26 __警卫 MessageQueue.js:265:6 CallFunctionReturnflushedqueue MessageQueue.js:115:17

我被困在这里,我尝试了很多事情,但没有成功

这是我的代码

drawernav.js

import React, { Component } from 'react';
import { DrawerNavigator} from 'react-navigation';
import Icon from "react-native-vector-icons/FontAwesome";
import stackNav from './stackNav';

const Drawer = DrawerNavigator({
    DrawerItem1: {
        screen: stackNav,
        navigationOptions: {
            drawerLabel: "Drawer Item 1",
            drawerIcon: ({ tintColor }) => <Icon name="rocket" size={24} />
        },
    },
    DrawerItem2: {
        screen: stackNav,
        navigationOptions: {
            drawerLabel: "Drawer Item 2",
            drawerIcon: ({ tintColor }) => <Icon name="rocket" size={24} />
        },
    }
});

export default Drawer;

TABNAV.JS

import React, { Component } from 'react';
import { TabNavigator, TabView } from 'react-navigation'
import Icon from "react-native-vector-icons/FontAwesome";
import MainScreen from './screens/MainScreen';
const tabNav = TabNavigator({
    TabItem1: {
        screen: MainScreen,
        navigationOptions: {
            tabBarLabel:"Tab One",
            tabBarIcon: ({ tintColor }) => <Icon name={"glass"} size={30} color={tintColor} />
        }
    },
    TabItem2: {
        screen: MainScreen,
        navigationOptions: {
            tabBarLabel:"Tab Two",
            tabBarIcon: ({ tintColor }) => <Icon name={"glass"} size={30} color={tintColor} />
        }
    },
    TabItem3: {
        screen: MainScreen,
        navigationOptions: {
            tabBarLabel:"Tab Three",
            tabBarIcon: ({ tintColor }) => <Icon name={"glass"} size={30} color={tintColor} />
        }
    }
    ///... add more tabs here
}, {
        tabBarPosition: 'bottom',
        tabBarOptions: {
            activeTintColor: '#222'
        },
});

export default tabNav;

stacknav.js

import React, { Component } from 'react';
import { TouchableOpacity } from 'react-native';
import { StackNavigator} from 'react-navigation'
import IOSIcon from "react-native-vector-icons/Ionicons";
import DetailScreen from './screens/DetailScreen';
import MainScreen from './screens/MainScreen';
import tabNav from './tabNav'
const stackNav = StackNavigator({
    Main: {
        screen: tabNav,
        navigationOptions:({navigation}) => ({
            title: "Main",
            headerLeft:(
              <TouchableOpacity onPress={() => navigation.navigate("DrawerOpen")}>
                <IOSIcon name="ios-menu" size={30} />
              </TouchableOpacity>
            ),
            headerStyle: { paddingRight: 10, paddingLeft: 10 },
        })
    },
    Detail: {
        screen: DetailScreen,
        navigationOptions: (props) => ({
            title: "Detail",
        })
    }
})
export default stackNav;

我与tabnavigator有相同的错误。

我还执行了官方的React-Navigation示例(https://github.com/reaect-community/reacmunity/react-navigation/blob/master/master/examples/navigationplayground/js/simpletabs.js无成功(没有成功))。

我的猜测是这是最新版本的expo/react本地版本的错误。

您正在使用哪些版本?

我正在使用:

"dependencies": {
    "expo": "^22.0.2",
    "react": "16.0.0-beta.5",
    "react-native": "^0.49.5",
    "react-navigation": "^1.0.0-beta.20"
  }

已确认的:从创建React Antive App弹出的问题解决了问题。因此,这似乎是创建React Antive App或Expo的错误。

相关内容

  • 没有找到相关文章

最新更新