【发布时间】:2018-06-07 13:52:37
【问题描述】:
我最近在应用中添加了一个新屏幕,该屏幕只需要特定类型的登录用户才能访问。
class DemoScreen extends Component {
static navigationOptions = {
title: 'Title',
drawerLabel: ({ tintColor, focused }) => {
return (
<MainMenuItem
textKey={TEXTKEY}
iconName="cellphone-settings"
focused={focused}
tintColor={tintColor}
/>
);
}
};
// Skipping rest of the code
}
此组件连接到 redux 存储,因此它可以访问用户信息。但是this.props.<FIELD>不能在navigationOptions里面访问。
我的路线是这样的
const MainMenu = DrawerNavigator(
{
// Other screens here
Demo: { screen: DemoScreen },
},
{
drawerWidth: 250,
drawerPosition: 'left',
contentComponent: MenuDrawerContent,
contentOptions: drawerContentOptions
}
);
export const Routes = {
// Other routes here
Main: {
screen: MainMenu,
navigationOptions: {
gesturesEnabled: false
}
}
};
我想要的是仅向特定类型的登录用户显示 DemoScreen MainManuItem。我该如何做到这一点?这个逻辑应该在哪里?
谢谢。
【问题讨论】:
标签: reactjs react-native redux react-navigation