I am wondering if there is a way to have onPress and onLongPress on the same button/TouchableOpacity, in react-native with javascript, If so how do I do that?
Yes, according to the docs, you can add an onPress
and onLongPress
props.
For the record, TouchableOpacity inherits all the props available on TouchableWithoutFeedback.
<TouchableOpacity
onPress={() => { console.log("onPress") }}
onLongPress={() => { console.log("onLongPress") }}
>
...
</TouchableOpacity>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With