How to call Actions.xxx in functions binded to onPress event in 'react-native-router-flux'

删除回忆录丶 提交于 2020-01-07 02:01:22

问题


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?


回答1:


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>
    );
  }
}

Hope this can he helpful.



来源:https://stackoverflow.com/questions/37346979/how-to-call-actions-xxx-in-functions-binded-to-onpress-event-in-react-native-ro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!