Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading