[英]how can I hide some tabs on react native tab view?
I used tab view react native on my app and I want to hide some tabs by changing settings but I don't know how can I do that.我在我的应用程序上使用了选项卡视图反应本机,我想通过更改设置来隐藏一些选项卡,但我不知道该怎么做。 For now, I have 3 tabs: personal, company and material, in settings I can check the tabs, for example when company is not checked should not appears on tab view目前,我有 3 个选项卡:个人、公司和材料,在设置中我可以检查选项卡,例如,当未选中公司时,不应出现在选项卡视图中
constructor(props) {
super(props);
this.state = {
index: 0,
routes: [
{ key: 'personal', title: 'personal' },
{ key: 'company', title: 'company' },
{ key: 'material', title: 'material' }
],
};
}
_renderTabBar = props => {
return (
<View>
<TabBar
{...props}
indicatorStyle={{backgroundColor: 'white'}}
renderIcon={
props => this._getTabBarIcon(props)
}
onTabPress={ tab => this.changeTabs(tab)}
style={{backgroundColor: "#5243af"}}
tabStyle={styles.tabStyle}
labelStyle={{fontSize: Fonts.moderateScale(15), marginBottom: 10}}
contentContainerStyle={{height: Metrics.HEIGHT * 0.1, elevation: 0}}
/>
</View>
);
};
<TabView style={{ backgroundColor: 'white'}}
navigationState={this.state}
renderTabBar={ this._renderTabBar}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width}}
renderScene={this._renderScene} />
You should make custom own tabbar and manage the tab visibility according to condition, for more understanding follow this link您应该制作自定义标签栏并根据条件管理标签可见性,更多了解请点击此链接
Hide TabBar item in TabNavigator 在 TabNavigator 中隐藏 TabBar 项
it will help you它会帮助你
tabBar hidden =>
<TabView
renderToTabbar={ ()=> <></> }
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.