React Native Pressable onPressIn only called when OnPress handler is present

650 Views Asked by At

In the android emulator, the following RN code does nothing (no log, no handler called)

<Pressable style={[styles.fullscreenContainer]}  
  onPressIn={()=> {console.log("onPress");this.props.touchHandler()}}>

However, if I insert a onPress handler, in otherwise exactly the same code, both logs appear and both handlers are called when the component is pressed.

<Pressable style={[styles.fullscreenContainer]}  
  onPress=  {()=> {console.log("onPress");  this.props.touchHandler()}} 
  onPressIn={()=> {console.log("onPressIn");this.props.touchHandler()}}>

Why does onPressIn not work on its own?

FYI onPressIn works correctly on iOS in the expo client

1

There are 1 best solutions below

0
On

onPressIn is followed by onPress, but if you haven't given onPress any logic to perform, then nothing will happen. You'll only get an onPressIn response, even though onPress is technically still triggered behind the scenes. (It's just a blank onPress).