我正在使用 react-navigation 并且有一个应用程序,drawerLabel
如果用户更改权限(版主与否),我需要能够动态更改
我在组件中设置了抽屉标签
static navigationOptions = {
title: 'Browse',
drawerLabel: 'My Bookings',
drawerIcon: ({tintColor}) => <Image source={navIcon} style={[styles.icon, {tintColor}]} />,
header: null,
};
我想我可以用 setPrams 更改标签,但以下似乎不起作用:
static getDerivedStateFromProps(props, state) {
if (props.admin) {
props.navigation.setParams({drawerLabel: 'Manage Bookings'});
}
}
我会如何改变drawerLabel
?
留下这个代码:
static getDerivedStateFromProps(props, state) {
if (props.admin) {
props.navigation.setParams({drawerLabel: 'Manage Bookings'});
}
}
并尝试改变这一点:
static navigationOptions = {
...
drawerLabel: 'My Bookings',
...
};
对此:
static navigationOptions = ({ navigation }) => {
const { params } = navigation.state;
return {
...
drawerLabel: params.drawerLabel || 'My Bookings',
...
}
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句