Reputation: 187
I'm having trouble returning the event object from onPress. What am I missing?
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>
Upvotes: 0
Views: 441
Reputation: 1
The onpress event returned undefined for me when I imported TouchableOpacity from react-native-gesture-handler. When I switched the import from react-native, it worked.
Upvotes: 0
Reputation: 79
There is no e and id variables in your code.
onPress={(e) => this.testEvent(e, id)}
Upvotes: 0