sejn
sejn

Reputation: 2674

How to make long press touch and hold in react-native

I need to longpress to make my chat to archive.(i.e) like whatsapp we have long press and make the chat to pin in the top

How can I make the same using react-native?

Upvotes: 4

Views: 16437

Answers (2)

Harshal Valanda
Harshal Valanda

Reputation: 5451

These long presses can be handled by passing a function to the onLongPress props of any of the Touchable components.

Delay in ms, from onPressIn, before onLongPress is called.

delayLongPress

<TouchableOpacity 
 style={[styles.modelView]}
 onLongPress={() => {
     console.log('Long Press')
 }}
 delayLongPress={3000}>
     <Image 
       style={[styles.modelSelection]}
       source={{ uri: 'image' }}
       resizeMode='contain'/>
</TouchableOpacity>

Upvotes: 9

Jacob
Jacob

Reputation: 926

What input type are you using?

If you are using any of the touchable components, you can use the onLongPress. More info on it here

Upvotes: 2

Related Questions