tabBarVisible:false对stackNavigation子节点不起作用

问题描述 投票:1回答:1

信息项目“react-navigation”:“^ 3.6.0”,“expo”:“^ 32.0.0”

我有一个TabNavigator,在这里我有重定向到孩子,这是StackNavigator。问题是在子节点内,我无法使用tabBarVisible:false隐藏tabNavigator

父母(TabNavigator)

import React from 'react';
import { Text } from 'react-native';
import { createBottomTabNavigator, createStackNavigator, createAppContainer } from 'react-navigation';
import { Home, Search, Add, Follow, Profile } from '../screens';
import HomeNavigator from './Home';
import SearchNavigator from './Search';

const config = {
    headerMode: 'none',
    tabBarPosition: 'top'
};

const screens = {
    Home: {
        screen: HomeNavigator,
        navigationOptions: ({navigation}) => ({
            title: 'Home',
        })
    }
};

const Authenticated = createBottomTabNavigator(screens, config);

export default createAppContainer(Authenticated);

儿童(StackNavigator)

import React from 'react';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import { Home, Profile } from '../screens';
import { Posts, Comments } from '../screens/screensHome';

const screens = {
    Home: {
        screen: Home,
        navigationOptions: {
            header: null,
        }
    },
    Comments: {
        screen: Comments
    }
};

const HomeNavigation = createStackNavigator(screens, config);

export default createAppContainer(HomeNavigation);

视图(宽度导航选项)

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

export default class Comments extends Component {

    static navigationOptions = {
        tabBarVisible: false
    }

    render() {
        return (
            <View>
                <Text>I'm the Comments component</Text>
            </View>
        );
    }
}

我留下了应用程序的代码

https://snack.expo.io/@ricarquico/clone-instagram

总之,我想隐藏这个http://prntscr.com/n6hw68

javascript reactjs react-native react-navigation react-native-navigation
1个回答
0
投票

我不确定你是否尝试过这个。 https://snack.expo.io/Sk7Go1WRM

关于Github的问题:https://github.com/react-navigation/react-navigation-tabs/issues/19

StackA.navigationOptions = ({navigation})=>{
let { routeName } = navigation.state.routes[navigation.state.index];
   let navigationOptions = {};
   if (routeName === 'Comments') {
      navigationOptions.tabBarVisible = false;
   }
    return navigationOptions;
}
© www.soinside.com 2019 - 2024. All rights reserved.