react-native
react-native copied to clipboard
onPress not fire occasionally when pressing
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
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>
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
facing the same issue, onPressIn is called everytime but onPress event somehow isn't called, any leads?
This looks similar to my issue, do you observe the same behaviour? https://github.com/facebook/react-native/issues/36710
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
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。
seeing this issue as well, on all Touchable and Pressable elements, investigating, will report back
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
Any updates on this?
It reproduces in react-native: 0.72.6
same issue on "react-native": "0.72.3"
Any updates on this?
nope they are not fixing it apparently