react-native icon indicating copy to clipboard operation
react-native copied to clipboard

onPress not fire occasionally when pressing

Open flixyudh opened this issue 2 years ago • 2 comments

Description

onPress props not always run (occasionally) each time pressed

Version

0.70.3

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 12.5.1
  CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
  Memory: 37.07 MB / 16.00 GB
  Shell: 5.8.1 - /bin/zsh
Binaries:
  Node: 16.13.2 - /usr/local/bin/node
  Yarn: 1.22.10 - /usr/local/bin/yarn
  npm: 8.5.5 - /usr/local/bin/npm
  Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
  CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
  Android SDK:
    API Levels: 27, 28, 29, 30, 31
    Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0
    System Images: android-23 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: 4.1 AI-201.8743.12.41.6953283
  Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
Languages:
  Java: 11.0.13 - /usr/bin/javac
npmPackages:
  @react-native-community/cli: Not Found
  react: 18.1.0 => 18.1.0 
  react-native: 0.70.3 => 0.70.3 
  react-native-macos: Not Found
npmGlobalPackages:
  *react-native*: Not Found

Steps to reproduce

use any Touchable component (Pressable, TouchableOpacity, etc) and put console.log in onPress function

Snack, code example, screenshot, or link to a repository

var showup = 0

<TouchableOpacity
  onPress={() => {
    showup += 1;
    console.log("LOGGED", showup);
  }}
  delayPressIn={0}
>
  <Text> SHOW LOG </Text>
</TouchableOpacity>

https://user-images.githubusercontent.com/19633881/196044831-df3bac79-4296-427b-a1b1-eac0a01b158f.mp4

flixyudh avatar Oct 16 '22 15:10 flixyudh

Use useState

Example

const [shopUp,setShopUp] = useState(0)

const increment = () => {
     setShopUp(shopUp + 1)
}
<TouchableOpacity
  onPress={increment}
  delayPressIn={0}
>
  <Text> SHOW LOG </Text>
  <Text>{shopUp}</Text>
</TouchableOpacity>

ahmetbilgay avatar Oct 18 '22 21:10 ahmetbilgay

it's about the onPress it self, you can see in my video at 8th second i've spam button but the onPress not trigger even the opacity has already show up

flixyudh avatar Oct 22 '22 07:10 flixyudh

facing the same issue, onPressIn is called everytime but onPress event somehow isn't called, any leads?

srinivastalnikar avatar Jan 20 '23 13:01 srinivastalnikar

This looks similar to my issue, do you observe the same behaviour? https://github.com/facebook/react-native/issues/36710

vrgimael avatar Mar 29 '23 23:03 vrgimael

I couldn't reproduce this issue with the information provided. Sometimes onPress is cancelled by long press and other scenarios (see here). Difficult to tell if any of those situations are occurring in your case, or if it's something else, as there's no test case included. Going to close this in favor of #36710

necolas avatar Mar 30 '23 20:03 necolas

do you have the new architecture on ? I face the same case when I turn on new architecture,but everything is ok when i turn off new architecture。

ziXiong avatar Jun 02 '23 10:06 ziXiong

seeing this issue as well, on all Touchable and Pressable elements, investigating, will report back

frozencap avatar Aug 19 '23 14:08 frozencap

do you have the new architecture on ? I face the same case when I turn on new architecture,but everything is ok when i turn off new architecture。

+1 When the new arch is enabled, sometimes onPress is not triggered

renopp avatar Aug 29 '23 07:08 renopp

Any updates on this?

xts-bit avatar Sep 06 '23 10:09 xts-bit

It reproduces in react-native: 0.72.6

nickschinestzki avatar Nov 01 '23 15:11 nickschinestzki

same issue on "react-native": "0.72.3"

airam666 avatar Dec 28 '23 22:12 airam666

Any updates on this?

nope they are not fixing it apparently

airam666 avatar Dec 28 '23 22:12 airam666