[英]How to switch screens using React Navigation Drawer
I have the following navigation structure:我有以下导航结构:
Example Drawer contents示例抽屉内容
How would I add the labels of and navigate to 'Settings, Legal info' through the drawer?我将如何通过抽屉添加标签并导航到“设置,法律信息”? Extra: 'Profile' label shouldn't show on the drawer.额外:“个人资料”标签不应显示在抽屉上。
A similar example is the Instagram drawer in the profile tab.一个类似的例子是个人资料选项卡中的 Instagram 抽屉。 When you chose an option it pushes a new screen.当您选择一个选项时,它会推送一个新屏幕。
Thanks in advance.提前致谢。
I've come up with clunky yet working solution.我想出了笨拙但有效的解决方案。
Drawer navigation routes抽屉导航路线
`...
// To hide a specific route (Profile)
HiddenLabel:{
screen:ScreenA,
navOptions:{
drawerLabel:()=>null
}
}
A:{
screen:()=>null
navOptions:{
drawerLabel:'Settings'
}
}
...`
Drawer navigation custom component抽屉导航自定义组件
`
...
contentComponent:(props)=>(
// Should be wrapped in SafeAreaView
<DrawerItems {...props} onItemPress={
({route})=>{
// query and use props.navigation to navigate to route.routeName
}
}/>
)
...
`
And that's pretty much it.仅此而已。 If you have another solution please do post it.如果您有其他解决方案,请发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.