【问题标题】:tabBarVisible: false does not work on a stackNavigation childtabBarVisible: false 不适用于 stackNavigation 子项
【发布时间】:2019-04-02 11:23:01
【问题描述】:

信息项目 “反应导航”:“^3.6.0”, “世博”:“^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


    【解决方案1】:

    我不确定你是否尝试过这个。 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;
    }
    

    【讨论】:

    猜你喜欢
    • 2020-08-26
    • 2020-05-21
    • 2014-02-26
    • 2019-01-25
    • 2014-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多