Search code examples
react-nativetouchableopacity

TouchableOpacity:Why did not trigger onPress,But triggered onLongPress?


<TouchableOpacity
    onPressIn={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressIn') }}
    onPressOut={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressOut') }}
    onPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPress') }}
    onLongPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onLongPress') }}>

    <Image
        source={{ uri: item.images.medium }}
        style={styles.item_image}
    />

</TouchableOpacity>

console.log

1574921523 "onPressIn"
1574921523 "onLongPress"
1574921523 "onPressOut"

Why did not trigger onPress,But triggered onLongPress?

https://facebook.github.io/react-native/docs/touchablewithoutfeedback#onlongpress

image: console.log


Solution

  • I am also facing the same issue while development, as onLongpress and onPress both not working smoothly, but when i have made a build then it is working as expected.

    So try to make the build of the app, and it will work fine
    

    Hope this helps....Thanks :)