I have a problem with my React Native Component.
sayHi = (s) => {
console.log('hey' + s)
}
renderListItem(item, i) {
return (
<TouchableOpacity
key={i}
style={styles.listItem}
onPress={() => { this.sayHi('bob') }}>
<Text>{item}</Text>
</TouchableOpacity>
)
}
render() {
this.sayHi('patrick')
const { list } = this.props
return (
<View>
{list.map(this.renderListItem)}
</View>
)
}
In renderListItem I get an error _this2.sayHi is not a function.
Searched online but most posts do not fit my situation; I took a look at this post but I already have an arrow function so it's not a context problem.
The function console logs just fine in the render().
I tried to bind the this in the constructor but I still get the error.