Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to have "onPress" and "onLongPress" on same "Button/TouchableOpacity"

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?

like image 366
McKHAANNN Avatar asked Mar 07 '23 05:03

McKHAANNN


1 Answers

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>
like image 180
Dan Avatar answered Mar 14 '23 16:03

Dan