I don’t know if anyone is familiar with react native here but I am having trouble getting the id of the touched element. I have tried e.target.id and e.currentTarget.id and have also tried using value and key but everything is showing up undefined. I am really new to react native so I am not sure what is going wrong.
Here is my code:
return (
<View>
<TouchableOpacity key={index} disabled={disable} onPress={handleClick} id={index}>
<Image
style={styles.image}
source={{
uri: picArray[index]
}}
/>
</TouchableOpacity>
</View>
)
})}
</View>
const handleClick = (e) => {
let card = e.currentTarget.id
console.log(e.currentTarget.key)
console.log('hello')
/*
if (clickedOn.indexOf(card) != -1 && clickedOn.length > 0) {
setLoose("true")
}
if (clickedOn.indexOf(card) == -1 || clickedOn.length == 0) {
setClickedOn((clickedOn) => ([...clickedOn, card]));
}
*/
}