从抽屉导航器中删除屏幕



我对反应导航v2和drawerNavigator有反应原生问题。实际上,我希望抽屉导航器(标题(显示在屏幕上,但我不希望显示抽屉中的页面。

有我的主抽屉,我也想在ActionPage上显示它,但我不想在里面显示Action。

const MainDrawer = DrawerNavigator(
{
Home: {
screen: HomeStack,
navigationOptions: {
title: 'POČETNA',
}
},
OrderP: {
screen: OrderStack,
navigationOptions: {
title: 'NARUČI',
}
},
CatalogP: {
screen: CatalogStack,
navigationOptions: {
title: 'KATALOZI',
}
},
InstructionP: {
screen: InstructionStack,
navigationOptions: {
title: 'UPUTSTVO ZA PORUČIVANJE',
}
},
InfoP: {
screen: InfoStack,
navigationOptions: {
title: 'INFORMACIJE O APLIKACIJI'
}
},
ActionP: {
screen: ActionStack,
navigationOptions: {
header: null,
title: ''
}
}
}
);

和根堆栈:

const RootStack = StackNavigator(
{
MainDrawer: {
screen: MainDrawer,
},
Contact: {
screen: ContactPage
},
ActionP: {
screen: ActionPage
},
News: {
screen: NewsPage
}
},
{
headerMode: 'none'
}
);

为了隐藏您想要的页面,您可以调整以下代码:

// this const is used to hide desired pages
const hiddenDrawerItems = [
'Home',
'Profile',
]
const MainDrawer = createDrawerNavigator(
{
Home: { screen: HomePage },
Profile: { screen: ProfilePage },
// other pages
},
{
// this entry is used to actually hide you pages
contentComponent: (props) => {
const clonedProps = {
...props,
items: props.items.filter(item => !hiddenDrawerItems.includes(item.key)),
}
return <DrawerPage {...clonedProps} />
},
},
)

最新更新