reactjs - 在反应导航中从嵌套堆栈跳转到根目录中的一个屏幕
问题描述
我使用反应导航在我的反应原生项目中有以下根源: https ://i.stack.imgur.com/NA2gd.jpg
main 是一个带有 3 个屏幕的 bottomTabNavigator,在配置文件屏幕中我有一个 3 个屏幕的 topTabNavigator。在 EditProfile 屏幕中,我有一个注销按钮。当我按下注销按钮时,我想导航到登录屏幕。请帮我解决这个问题
解决方案
我在个人资料屏幕中自己找到了它,我像这样使用 screenProps:
class Profile extends Component{
constructor(props){
super(props);
}
render(){
return(
<View style={{ flex: 1,}}>
<AppNavigator screenProps={{ rootNavigation: this.props.navigation }}/>
</View>
)
}
}
并在用户触摸注销按钮时在 EditProfile 页面中运行此代码:
this.props.screenProps.rootNavigation.navigate('login')
推荐阅读
- android - Is it possible to add a network configuration on Android Q?
- python-3.x - pandas 读取文本文件并根据第一个字符将名称拆分为列
- string - Ansible filter output start with specific letter
- python - 如何使用 Python 获取存储库分支的列表
- reactjs - 选择文件后不显示图像 URL
- python - 如何解决错误:图像“pyimage1”不存在
- php - 使用 ajax 连接 mysql 和 html:在控制台中获取“不正确的字符”
- excel - 如何使用一张表过滤条件在多个工作簿中运行宏
- sql-server-2008 - 从 SSMS 2017 中的多维数据集浏览器复制/粘贴结果
- matlab - 在 MATLAB 中进行优化的符号计算