Example of Set onLongPress on Pressable in React Native

Hello friends, In today’s tutorial we would learn about onLongPress={ } function of Pressable button component in react native. The onLongPress event is used to set long press event on button. If we press button from more then 500 milliseconds then it will called. So in this tutorial we would learn about Example of Set onLongPress on Pressable in React Native. You can learn more about the Pressable Here.

Contents in this project Example of Set onLongPress on Pressable in React Native :-

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

2. Creating our main App component.

3. Creating a function named as callOnLongPress(). In this function we would simply print a Alert dialog box on screen.

4. Creating return() block, Now here we would make 1 Pressable Button component with onLongPress.

5. Creating Style.

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

Screenshots :-

Example of Set onLongPress on Pressable in React Native

Leave a Reply

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