Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance issue with Pressable in React Native with android [closed]

I noticed some performance-related issues on my React native app (Android Version) while using the React native API (Pressable). When pressed, it lags for some seconds before it responds especially when using it to navigate between screens. I don't seem to know why this is happening. It works perfectly on IOS.

I upgraded my React Native version to 0.71.2. I expected this to fix the lag but it did not

like image 719
Oluwafemi Akerele Avatar asked May 01 '26 17:05

Oluwafemi Akerele


2 Answers

I am sure the Pressable causes laggy more than other TouchableComponent, please see the code here:

Compare TouchableOpacity with Pressability

You can see Pressable is a heavy component, it holds more events, even it's own Gesture, hence I suggest to do not using Pressable many times, such as in the FlatList item...

like image 85
famfamfam Avatar answered May 04 '26 09:05

famfamfam


I encountered a similar issue in my project, and I found a solution that worked for me. I was using createStackNavigator from react-navigation, and I was experiencing lag on Android. After replacing it with createNativeStackNavigator, the performance issue was resolved. It might be worth trying out in your project as well. Good luck!

like image 36
Hamza Awais Avatar answered May 04 '26 08:05

Hamza Awais