Поскольку флаг NeedHide предустановлен в вашем хранилище редуксов, лучше всего создать собственную панель вкладок:
const AppNavigator = createBottomTabNavigator({
Find: {
screen: FindIndexPage,
},
Hot: {
screen: HotPage,
}
}, {
tabBarComponent: CustomTabBar
});
createAppContainer(AppNavigator));
Вы можете подключить эту панель вкладок к редуксу, как и любой другой компонент.,Обратите внимание, что я также ссылаюсь на CustomTabBarItem, это просто компонент, который вы создаете, чтобы отобразить значок и текст вкладки на основе индекса или routeName.
class CustomTabBar extends React.Component {
public render() {
const {navigation, needHide} = this.props;
// a navigator component receives a routes object, which holds all the routes of your tab bar
const routes = navigation.state.routes;
if (needHide) {
return <View/>;
};
return (
<SafeAreaView>
<View style={styles.container}>
{routes.map((route, index) => {
return (
<View style={styles.tabBarItem} key={route.routeName}>
<CustomTabBarItem
routeName={route.routeName}
onPress={this.navigationHandler}
focused={navigation.state.index === index}
index={index}
/>
</View>
);
})}
</View>
</SafeAreaView>
);
}
navigationHandler = (routeName: string) => {
this.props.navigation.navigate(routeName);
}
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignContent: 'center',
height: 80,
width: '100%',
},
tabBarItem: {
flex: 1,
alignItems: 'center'
}
});
const mapStateToProps = (state) => {
return {
needHide: state.changeMainBarVisibleReducer.needHide
};
};
export default connect(mapStateToProps)(CustomTabBar);