Search code examples
react-native-web

How to cancel Touchable onPress in favour of PanResponder in parent View


Before upgrading to React Native Web v0.13 a TouchableOpacity inside a View with PanResponder didn't trigger the onPress. In v0.13 it now get's triggered with the same setup. How can I make the onPress not fire, when PanResponder handles the event?

See my simple example at https://codesandbox.io/s/stoic-wu-u0utn The red rectangle is a TouchableOpacity which logs every time you press it. The outer blue rectangle is draggable. When dragging the red part, how can I make the onPress not to trigger? Change the version of React Native Web to 0.12.3 and see that it now works as expected.

(In my real app, this is a swipable list where you can both press and slide an item.)


Solution

  • This was fixed in in release 0.14.6, see https://github.com/necolas/react-native-web/commit/d2e6c29e259856b81d0466217754c1107a44f014