我在Router选项卡中定义了我的场景,如下所示:
<Scene
key="latest"
title="LATEST"
titleStyle={{flex:0}}
component={Latest}
onRight={()=>{}}
rightButtonImage={NOTIFICATION_ICON}
onLeft={()=>{}}
leftButtonImage={NAV_SEARCH_ICON}
/>使用上面的代码,我可以使用以下代码从我最新的屏幕执行导航操作:
componentDidMount() {
this.props.navigation.setParams({
'onRight': this.showNotifications,
'onLeft': this.showSearch,
})
}因此,为了从最新的屏幕更新rightButtonImage,我尝试在setParams()方法中添加rightButtonImage,如下所示:
this.props.navigation.setParams({
'onRight': this.showNotifications,
'onLeft': this.showSearch,
'rightButtonImage': {NOTIFICATION_ICON_ON}
})所以,基本上我想在新的通知到达时更改我的通知铃声图标。但是,在setParams()中添加'rightButtonImage‘是行不通的。
有谁能帮忙吗?
发布于 2019-03-18 07:41:12
试着起诉Actions.refresh
componentDidMount() {
Actions.refresh({
rightButtonImage : NOTIFICATION_ICON_ON // this should be an Image
});
}或者,您可以在Actions.refresh中使用renderRightButton
componentDidMount() {
Actions.refresh({
renderRightButton : XXXX // this should be an React.Component
});
}https://stackoverflow.com/questions/55161919
复制相似问题