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

用户3804063

我在“路由器”选项卡中定义了我的场景,如下所示:

<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'无效。

有人可以帮忙吗?

穆罕默德·阿巴斯

尝试起诉 Actions.refresh

componentDidMount() {
  Actions.refresh({
    rightButtonImage : NOTIFICATION_ICON_ON // this should be an Image
  });
}

或者您可以renderRightButtonActions.refresh

componentDidMount() {
  Actions.refresh({
    renderRightButton : XXXX // this should be an React.Component
  });
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何将值传递给React-Native-Router-Flux中的其他组件?

react-native-router-flux-特定路由负载上的触发功能

如何将react-native-router-flux与react-native-drawer结合使用

React Native Router Flux:从主场景导航到子场景

是否可以在react-native-router-flux中向NavBar添加自定义按钮?

使用React Native Router Flux将道具传递到TabIcon中

添加react-native-router-flux Action()之后,“警告:setState(...):在现有状态转换期间无法更新”

react-native-router-flux禁用android back按钮从返回到登录屏幕

使用react-native-router-flux自定义navBar

使用React Native Router Flux / Redux保护路由(场景)

如何设置react-native-router-flux?

使用React Native Router Flux的延迟加载屏幕

react-native-router-flux将道具传递给场景

React-Native-Router-flux防止多次点击

使用react-native-router-flux将数据从屏幕发送到Tab屏幕

如何在React Native Router Flux选项卡中显示图标?

转到子场景选项卡-react-native-router-flux

我如何将react-native-router-flux与Relay集成在一起

react-native-router-flux,重载时保持状态

React Native + react-native-router-flux:如何将hideNavBar应用于仅一个<Scene />?

react-native:如何结合 react-native-router-flux 和 react-native-drawer?

在 react-native-flux-router 中传递道具

在 react-native-router-flux 上从堆栈中弹出导航

使用 react-native-router-flux 无法正确显示导航栏和选项卡

在 React Native Router Flux 中跨主要场景导航

如何通过 react-native-router -flux 在 react-native 中更新回(上一个)屏幕

如何使用 react-native-router-flux 设置作为选项卡子项的场景的标题

如何配置 react-native-router-flux android back history?

未找到 React Native 模塊:無法使用 react-native-router-flux 解析“@react-navigation/core”