TouchabelOpacity works fine on iOS but the onPress method does not work on Android for me.
My react-native version: 0.57.4
My code:
const initDrawer = navigation => ( <TouchableOpacity style={{ left: 16 }} onPress={() => onPressDrawerButton(navigation)} > <Ionicons name="ios-menu" color="white" size={30} /> </TouchableOpacity> );
TouchabelOpacity works fine on iOS but the onPress method does not work on Android for me. I can confirm it works fine on Android with version 0.57. 7.
Pressable is all-in-one touchable components Pressable component has all the features of Touchable components. Therefore, we can replace all TouchableOpacity, TouchableHighlight, TouchableNativeFeedback and TouchableWithoutFeedback with a single component.
On press down, the opacity of the wrapped view is decreased, dimming it. Opacity is controlled by wrapping the children in an Animated. View , which is added to the view hierarchy.
To add image and onPress into touchable with React Native, we can set the onPress prop on the TouchableHighlight and put the Image the TouchableHighlight . to set onPress to a function that logs 'pressed' . And we put the Image inside. Asa a result, we see 'pressed' logged when we click on the image.
I had similar problem. Pay attention from where import your "TouchableOpacity". When I changed "TouchableOpacity" from "react-native-gesture-handler" to "react-native", it worked for me (for Android platform)
I had the same issue, all TouchableOpacity buttons were working fine in iOS build, but there was one in Android that did not fire. I stumbled upon this answer here that mentioned that position: absolute
would mess up the trigger. It solved my issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With