给定以下列出的StackNavigator选项:
static navigationOptions = {
title: 'Main',
headerRight: (
<MaterialIcons name="grid-on" size={26}/>
),
};我想改变图标在headerRight后,用户按下它,我如何实现它?
发布于 2018-09-22 18:09:36
这就是你能做到的
static navigationOptions = ({ navigation }) => {
const { state } = navigation
if (state.params.yourCheck) {
return {
title: 'Your Title',
headerRight: (
<Button
title={'Button1'}
onPress={() => {
// do something
}}
/>
),
}
} else {
return {
title: 'Your Title',
headerRight: (
<Button
title={'Button2'}
onPress={() => {
// do something
}}
/>
),
}
}
}这是如何更改状态参数值的方法。
this.props.navigation.setParams({ yourCheck: false })https://stackoverflow.com/questions/52458115
复制相似问题