我在路由器选项卡中定义了我的场景,如下所示:
<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,
})
}
因此,为了从Latest屏幕更新rightButtonImage,我尝试在setParams()方法中添加rightButtonImage:
this.props.navigation.setParams({
'onRight': this.showNotifications,
'onLeft': this.showSearch,
'rightButtonImage': {NOTIFICATION_ICON_ON}
})
所以,基本上我想在新通知到来时更改我的通知铃图标。但是,通过在setParams()中添加'rightButtonImage'不起作用。
有人可以帮忙吗?
试着起诉Actions.refresh
componentDidMount() {
Actions.refresh({
rightButtonImage : NOTIFICATION_ICON_ON // this should be an Image
});
}
或者你可以在renderRightButton
中使用Actions.refresh
componentDidMount() {
Actions.refresh({
renderRightButton : XXXX // this should be an React.Component
});
}