首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >React-native-router-flux动态更新rightButtonImage

React-native-router-flux动态更新rightButtonImage
EN

Stack Overflow用户
提问于 2019-03-14 19:55:28
回答 1查看 448关注 0票数 3

我在Router选项卡中定义了我的场景,如下所示:

代码语言:javascript
复制
<Scene 
         key="latest"
         title="LATEST"
         titleStyle={{flex:0}}
         component={Latest}
         onRight={()=>{}} 
         rightButtonImage={NOTIFICATION_ICON}
         onLeft={()=>{}}
         leftButtonImage={NAV_SEARCH_ICON}
/>

使用上面的代码,我可以使用以下代码从我最新的屏幕执行导航操作:

代码语言:javascript
复制
  componentDidMount() {
          this.props.navigation.setParams({
               'onRight': this.showNotifications,
               'onLeft': this.showSearch,
         })
  }

因此,为了从最新的屏幕更新rightButtonImage,我尝试在setParams()方法中添加rightButtonImage,如下所示:

代码语言:javascript
复制
 this.props.navigation.setParams({
      'onRight': this.showNotifications,
      'onLeft': this.showSearch,
      'rightButtonImage': {NOTIFICATION_ICON_ON}
    })

所以,基本上我想在新的通知到达时更改我的通知铃声图标。但是,在setParams()中添加'rightButtonImage‘是行不通的。

有谁能帮忙吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-18 07:41:12

试着起诉Actions.refresh

代码语言:javascript
复制
componentDidMount() {
  Actions.refresh({
    rightButtonImage : NOTIFICATION_ICON_ON // this should be an Image
  });
}

或者,您可以在Actions.refresh中使用renderRightButton

代码语言:javascript
复制
componentDidMount() {
  Actions.refresh({
    renderRightButton : XXXX // this should be an React.Component
  });
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55161919

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档