如何在与"react-native-router-flux"中的onPress事件绑定的函数中调用Actions.xxx [英] How to call Actions.xxx in functions binded to onPress event in 'react-native-router-flux'

查看:57
本文介绍了如何在与"react-native-router-flux"中的onPress事件绑定的函数中调用Actions.xxx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RN0.24和flux3.26. RN版本可能已过时,但是当我使用onPress={Actions.xxx}Actions.xxx可以正常工作 但是,一旦我将其放入类似onPress={this.function}的函数中,并且在函数中 function(event){ Actions.xxx; }则不起作用 有人能帮忙吗?

I'm using RN0.24 and flux3.26. RN version may be out-dated but the Actions.xxx works fine when I'm using onPress={Actions.xxx} However once I put it into functions like onPress={this.function} and in function i do function(event){ Actions.xxx; } then it's not working can anyone help with this?

推荐答案

这是一个this问题,我想您可以尝试:

This is a this issue, I think you can try:

render() {
    const login = () => { Action.login() }
    return (
      <View style={styles.container}>
        <Text style={styles.welcome} onPress={ login }>
          Go to Login
        </Text>
      </View>
    );
  }
}

希望这对他有帮助.

这篇关于如何在与"react-native-router-flux"中的onPress事件绑定的函数中调用Actions.xxx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆