信息项目 “反应导航”:“ ^ 3.6.0”, “ expo”:“ ^ 32.0.0”
我有一个TabNavigator,在其中我具有对子级的重定向,即StackNavigator。问题是在子级中,我无法使用tabBarVisible隐藏false:false
父母(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);
视图(宽度navigationOptions)
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
答案 0 :(得分: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;
}