question-mark
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 called after holding a button for longer than a second (iOS) (since 0.62)

See original GitHub issue

Description

Since upgrading to 0.62.2 it seems that every “React Native” button (Button, TouchableHighlight etc.) cancels the onPress when pressing a button for longer than a second. I have an app still running on 0.61.5 and there it will still call the onPress after holding a button for longer than a second and releasing it. Is this any new intended behavior? Native libraries like: https://github.com/react-native-community/segmented-control don’t have this behavior.

React Native version:

0.62.2

Steps To Reproduce

  1. Create a new project with npx react-native init AwesomeProject
  2. Press any of the buttons below “Learn More” for longer than a second and release.

Expected Results

I expected that the onPress would be called and I am redirected to the corresponding docs. In an Expo snack, I am still seeing the expected results: https://snack.expo.io/@dylancom/2d8052 Probably due to that Expo SDK 37 is using React Native 0.61

Code example:

import { Button } from 'react-native';

<Button
  onPress={() => alert('I should be called')} 
  title="Hold for > a second and release"
/>

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
yungsterscommented, Sep 11, 2020

Ahh… good catch. This was a mistake on my part in the migration for TouchableBounce (not technically exported in the Public API) and TouchableHighlight. I’ll send a fix for it right now.

0reactions
yungsterscommented, Jan 11, 2021

@TomasSestak Correct. If onLongPress is not supplied, onPress will be fired regardless of how long a user presses down.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native onPress being called automatically
The reason is that onPress takes a function as an argument. In your code, you are calling the function and returning the result...
Read more >
React Native v0.63.3 Release - GitClear
onPress not called after holding a button for longer than a second (iOS) (since 0.62) ... Fix default nxapi port setting when use_ssl...
Read more >
Restart your iPhone - Apple Support
Press and hold either volume button and the side button until the power-off slider appears. The volume button is located on the left...
Read more >
Press home button to upgrade (broken home button) - iFixit
I FOUND THE FIX! After a successful update or restore, plug the device into itunes, then set up as new ipad. Go to...
Read more >
React Native touchable vs. pressable components
Feel free to jump around this post, too, since we'll be covering a lot: React Native touchable components. Creating a native button ......
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found