React native TouchableOpacity onPress not working on Android
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.
Terminating the metro server (in case it's currently running) and then running it all again (like below) worked for me.
on the console running the metro server, terminate it
ctrl + c
then on the another console, run your app
react-native run-android
or
npx react-native run-android
For me, it was working, but the touchable area was very small. Somehow the area in iOS was bigger than in Android.
I ended up increasing the touchable area using the hitSlop
property as below:
<TouchableOpacity
onPress={() => {}}
hitSlop={{ top: 30, bottom: 30, left: 30, right: 30 }}
>
<Icon name="eye" />
</TouchableOpacity>