简体   繁体   English

DrawerItems没有从StackNavigator中显示(反应导航)

[英]DrawerItems not showing from StackNavigator (react-navigation)

Currently Im trying to make a drawer using react-navigation. 目前,我正在尝试使用反应导航制作抽屉。 my react-navigation version is : "^1.0.0-beta.7" 我的react-navigation版本是:“ ^ 1.0.0-beta.7”

Basically my structure of react-navigation look like this 基本上我的反应导航结构看起来像这样

StackNavigator as the root.. DrawerNavigator as the 2nd layer.. and another StackNavigator as the 3rd layer.. 根目录为StackNavigator,第二层为DrawerNavigator,第三层为另一个StackNavigator。

My problem is that when I put my component inside DrawerNavigator, The Component header will not show up after navigate to the component.. So, Im hoping anyone who can pointed to me how to make header visible when I put my component inside DrawerNavigator. 我的问题是,当我将组件放入DrawerNavigator时,导航到该组件后将不会显示Component标头。因此,我希望有人能指出我如何将组件放入DrawerNavigator时使标头可见。 If I did not put any component inside DrawerNavigator and all the screen inside the inner StackNavigator, the header will be visible but then the DrawerItems doesnt have any props thus not showing inside the drawer. 如果我没有在DrawerNavigator内放置任何组件,而在内部StackNavigator内没有放置所有屏幕,则标题将可见,但是DrawerItems没有任何道具,因此不会在抽屉内显示。

 const rootNav = StackNavigator({ MainDrawerNavigator: { screen: MainDrawerNavigator } }, { headerMode: 'screen', navigationOptions: { header: null } }) const MainDrawerNavigator = DrawerNavigator({ Home: { screen: HomeNavigator }, Logout: { screen: Logout } },{ initialRouteName: 'Home', drawerWidth: 270, headerMode: 'screen', contentComponent: (props) => { return( <ScrollView> <DrawerItems {...props} /> </ScrollView> ) }, contentOptions: { style: { marginTop: 0, } } }) const HomeNavigator = StackNavigator({ HomeMenu: { screen: HomeMenu }, StartJourney: { screen : StartJourney }, JournalList: { screen: JournalList }, )} 

在此处输入图片说明

Hope anyone can help me with this. 希望任何人都可以帮助我。 Thanks! 谢谢!

I'm trying to achieve where DrawerOpen the header will not show 我正在尝试实现DrawerOpen标头不会显示的位置

I don' understand which header here is? 我不明白这里是哪个标题?

but when I navigate the route from Drawer and it open a screen, then the header will show up 但是,当我从“抽屉”导航路线并打开一个屏幕时,标题将显示

If you're talking about navigator header, it's header of HomeNavigator , you can do like you did with rootNav navigationOptions: { header: null } 如果您正在谈论导航器标头,它是HomeNavigator的标头,则可以像使用rootNav navigationOptions: { header: null }一样进行操作navigationOptions: { header: null }

 const HomeNavigator = StackNavigator({
    HomeMenu: { screen: HomeMenu },
    StartJourney: { screen : StartJourney },
    JournalList: { screen: JournalList },
},{
navigationOptions: { header: null }
})

And current react-navigation document is for beta.9 / beta.10 I don't know if these props work on beta.7 . 目前的反应导航文档是针对beta.9 / beta.10我不知道这些道具是否适用于beta.7 There are some big changes on style and props from beta.7 to beta.8 从beta.7到beta.8,样式和道具都有一些大的变化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM