javascript - 连接 MaterialBottomTabNavigator 和其他不属于它的屏幕
问题描述
所以我正在研究 MaterialBottomTabNavigator,我遇到了这个小问题。我有4个屏幕。代码如下所示:
const bottomNavigator = createMaterialBottomTabNavigator(
{
home: {
screen: HomeScreen,
navigationOptions : {
tabBarIcon: <Icon type="FontAwesome" name="home" style={{color:'#fff'}} />,
title:'Home',
}
}
trending: {
screen: TrendingScreen,
navigationOptions : {
tabBarIcon: <Icon type="FontAwesome" name="fire" style={{color:'#fff'}} />,
title:'Trending'
}
},
profile: {
screen: ProfileScreen,
navigationOptions : {
tabBarIcon: <Icon type="FontAwesome" name="id-badge" style={{color:'#fff'}} />,
title:'Profile'
}
},
settings: {
screen: SettingsScreen ,
navigationOptions : {
tabBarIcon: <Icon type="FontAwesome" name="cog" style={{color:'#fff'}} />,
title:'Settings'
}
}
},
{
initialRouteName: 'home',
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: { backgroundColor: UI_COLORS['foxy'] },
}
);
现在,我可以在这些屏幕之间发送信息了。HomeScreen、TrendingScreen、ProfileScreen,但我遇到的问题是当我必须打开另一个不是它的一部分的屏幕时。如何从这些屏幕中的任何一个导航到屏幕说“DiffScreen”。即假设我在 HomeScreen 中,并且我想转到不属于底部导航器的“DiffScreen”。任何帮助,我怎样才能到达那个屏幕?类似
this.props.navigation.navigate('DiffScreen')
或类似的东西我只是在这里感觉到一点redux需求,但如果我可以没有它会更好。
解决方案
推荐阅读
- dart - 如何在 Dart 中通过 async* 传输错误?
- javascript - JavaScript - Express - MongoDb - Mongoose findOneAndUpdate 返回未定义
- android - Google Play 服务位置 API:如何在启用/禁用时接收广播消息?
- javascript - 如何将修复滑块更改为高度和宽度的响应滑块
- python - 如何在python中递归地表示无限嵌套的分数
- sql - 当月末是周中时,如何提取周结束日期和月末
- javascript - 在 React 中预加载图像的最有效方法是什么?值得付出努力吗?
- c# - 如何为 api 编写异步获取请求
- ms-access - 如何在图片控件上设置默认图片?
- database - 本地 PC 的规格是否会影响运行 Microsoft Access 查询所需的时间?