html - 使用堆栈导航的选项卡导航中的不良行为
问题描述
我正在使用堆栈导航设置选项卡,当我尝试更改组件时出现意外行为。当我浏览选项卡时,我想打开堆栈导航的第一个组件。请查看此视频,以便您了解我的意思。
我尝试传递道具“initialRouteName”但不起作用。这是我的代码:
const familyStackNavigator = createStackNavigator({
main: { screen: parentFamilyScreen },
resume: { screen: ResumeChildScreen }
},
{
mode: 'modal',
headerMode: 'none',
initialRouteName: 'main',
});
const parentAppStack = createMaterialBottomTabNavigator({
family: {
screen: familyStackNavigator,
navigationOptions: {
tabBarIcon: FirstTabIcon,
title: 'Familia'
}
},
bag: {
screen: parentBagScreen,
navigationOptions: {
tabBarIcon: SecondTabIcon,
title: 'Bolsillo'
}
},
{
initialRouteName: 'family',
activeColor: '#ED0F21',
inactiveColor: '#333333',
barStyle: { backgroundColor: 'white' },
labeled: true
})
解决方案
您在这里有 2 个选择:
要么隐藏你bottomTabNavigator
的嵌套屏幕内以防止它导航,要么使用react-navigation
的导航事件。
这些是文档https://reactnavigation.org/docs/en/navigation-events.html用于在渲染中声明它们
这些是用于在屏幕内添加 eventListener的文档https://reactnavigation.org/docs/en/navigation-prop.html#addlistener-subscribe-to-updates-to-navigation-lifecycle
然后你可以使用 willBlur 来做pop(1)
你的屏幕
推荐阅读
- c++ - 在套接字接收阻塞等待数据时保持窗口运动和关闭操作?
- r - 我们可以使用 R purrr 累积函数来汇总数据集吗?
- python - 如何手动或使用绘图插件(folium - Python)添加标记并能够导出或保存它?
- arrays - 如何在 Excel 中快速填充数据范围?
- amazon-web-services - AWS Amplify - CognitoIdentityCredentials 无权执行:sts:AssumeRole on resource
- react-native - React / Ionic:无效的钩子调用问题(使用历史记录进行重定向)
- c# - 如何使用 CsvHelper 从 ASP.NET MVC 中具有参数的方法生成 CSV
- reactjs - 有没有办法在 React 中只使用不同的子域调用 api?
- javascript - 动态类名样式
- node.js - 我的应用程序中有两个错误,1 漏洞太多,2 我无法推送到 heroku