React Native: Text onPress not working on android


I have the following code:

<Text onPress={() => console.log('this won\'t print')}>Dumb text</Text>

According to React Native’s documentation, this works great in both iOS and Android, however when I run it myself, it only works on iOS, while Android acts as if the onPress prop doesn’t exist at all.

I know I can use TouchableOpacity (all other questions talk about this), but I just need confirmation on whether I am missing something or if this is how it always has been and the documentation is incomplete.

>Solution :

Your code seems perfectly right and works for me… Try reloading or reinstalling the app 2-3 times.. It should work

This is what I tried and worked :

<Text style={{color:'white', fontSize : 50}} onPress={() => console.log("pressed")}>Hello</Text>

Leave a ReplyCancel reply