Example of Set onPress onClick on Text in React Native

Hello friends, As button the Text component does also support onPress event in react native. The onPress event is called when user touch or press the Text component. To Set onPress onClick on Text in React Native we have to use onPress={} prop in react native. The onPress event is supported by both Android and iOS platforms.

Contents in this project Example of Set onPress onClick on Text in React Native :-

1. Open your project’s main App.js file and import View, StyleSheet, Text and Alert component.

2. Creating our main Export default App component .

3. Creating a function named as showMessage() with Fat Arrow ()=> syntax. In the function we are simply print a Alert message on screen.

4. Now we would make the return() block and make 1 Text component with onPress={ } event and call above function in it.

5. Creating Style.

6. Complete Source Code for App.js File :-

Screenshots :-

Example of Set onPress onClick on Text in React Native

Leave a Reply

Your email address will not be published. Required fields are marked *