React Native onPress事件返回未定义

时间:2020-05-18 22:21:53

标签: react-native events onpress

我无法从onPress返回事件对象。我想念什么?

 constructor(props) {
    super(props)
    this.state = {
        user: null,
    }
    this.testEvent = this.testEvent.bind(this)
    }


    testEvent(e, id) {
        console.log(e)
     }


    <TouchableWithoutFeedback style={styles.rightGroupContainer} 
        onPress={(e) => this.testEvent(e, id)}>
     <Image source={this.closeIcon} style={styles.closeIcon}></Image>
     </TouchableWithoutFeedback>

1 个答案:

答案 0 :(得分:0)

您的代码中没有e和id变量。

onPress={(e) => this.testEvent(e, id)}
相关问题