Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onPress not working

See original GitHub issue

Issue Description

Describe the bug

I am not able to use onPress inside my SwipeableItem overlays. I started with the demo list from the README and added a onPress in addition to the onLongPress, but it’s never called.

Steps to reproduce the behavior:

Here’s a demo project. Long pressing to reorder works. But when you do a regular press it should change all the item texts to “An item was pressed”. Instead nothing happens.

Platform & Dependencies None in the demo project.

Platform (iOS/Android): React Native or Expo version: 0.61.5 react-native-reanimated version: 1.7.0 react-native-gesture-handler version: 1.5.6

Additional context

This is important functionality since you might want to show a new list when tapping, edit the item, etc. So primary action would be through tapping and secondary action(s) through swipes. My first idea for a workaround is to make a new component that extends TouchableOpacity or TouchableWithoutFeedback and uses onPressIn and onPressOut with some timers (although I would have guessed that’s exactly how TouchableWithoutFeedback is implemented). Or maybe to just act on onPressOut (if onDragBegin was never called). Have to investigate which events are called and when.

Do you have any idea why it’s not working? Seems like it might be nice to document this if a workaround is possible. And if a workaround is possible then it would make sense to me to integrate it into the library and add onPress and onLongPress directly to the SwipeableItem.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

computerjazzcommented, Feb 16, 2020

Removed TapGestureHandler in react-native-draggable-flatlist 2.3.0, please upgrade let me know if the onPress issue is fixed.

amazingmarvincommented, Feb 17, 2020

OK, sorry about the delay and thanks for letting me know about the new version! onPressIn, onPress, and onLongPress work as expected, whereas onPressOut is never called. This is fine for me since onPress is what I really need.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native onpress not working - Stack Overflow
First change onpress to onPress . Here () => this.onRadioPressed.bind(this) you are specifying an arrow function that returns another function ...
Read more >
onPress not working on web · Issue #1483 - GitHub
I encounter the same error using an icon wrapped inside TouchableWithoutFeedback I managed to remove the warning replacing it with the new react ......
Read more >
Handling Touches - React Native
The "Touchable" components provide the capability to capture tapping gestures, and can display feedback when a gesture is recognized. These ...
Read more >
React native TouchableOpacity onPress not working on Android
Android : React native TouchableOpacity onPress not working on Android [ Beautify Your Computer : ] ...
Read more >
react native svg onPress event not working on real device
Is <G> from the package that you're using for svg's? It may not have defined an onPress property or it might just be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found