【问题标题】:Define right button of NavBar in component, not in Scene (react-native-router-flux)在组件中定义 NavBar 的右键,而不是在场景中(react-native-router-flux)
【发布时间】:2018-11-08 10:53:11
【问题描述】:

我在我的应用中使用react-native-router-flux 进行导航。

我想在组件中定义NavBar的右键,而不是在Scene中,我该怎么做?

这是Scene的代码:

 <Scene
          navBar={PlatformNavbar}
          leftElement={  <Text style={{color: Colors.white, marginLeft: 25, fontWeight:'500' }}>Go Back</Text>  }
          key='nodScreen'
          component={NodScreen}
          hideNavBar={false}
        /> 

我正在使用我的自定义navBar,我有渲染左右元素的函数:leftElementrightElement

为了在组件中渲染正确的元素,我使用了这段代码,但是它没有渲染任何东西。

  componentDidMount() {
    Actions.refresh({rightElement: this.renderRightElement
  }) }

  renderRightElement = () => {
    return ( <TouchableOpacity onPress={() => {} }>
    <Image style={{height: 24, width: 24, marginRight: 16}} source={{uri: 'score_progress_empty'}} resizeMode='contain'/>
 </TouchableOpacity>)
  }

【问题讨论】:

    标签: react-native react-native-android react-native-router-flux


    【解决方案1】:

    您是否尝试过使用right 而不是rightElement

    componentDidMount() {
      Actions.refresh({
        right  : this.renderRightElement,
      })
    }
    

    查看 RNRF 页面上的this issue 了解更多详情

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 1970-01-01
      相关资源
      最近更新 更多