Search code examples
javascriptandroidreact-nativeperformancereact-navigation

Performance issue with Pressable in React Native with android


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


Solution

  • 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...