0
0
React Nativemobile~8 mins

TouchableOpacity and TouchableHighlight in React Native - Build, Publish & Deploy

Choose your learning style9 modes available
Build & Publish - TouchableOpacity and TouchableHighlight
Performance Impact

Using TouchableOpacity and TouchableHighlight affects UI responsiveness and battery life. Both provide visual feedback on touch, which helps users know their tap was registered. TouchableOpacity changes the opacity smoothly, which is GPU-accelerated and usually runs at 60fps without lag. TouchableHighlight changes background color instantly, which is also efficient but can cause slight frame drops if overused with complex children.

Memory usage is minimal for both, but excessive nesting or heavy children inside these touchables can increase memory and slow rendering.

Optimization Tips
  • Use TouchableOpacity for simple fade effects; it is lighter on the GPU and smoother.
  • Limit the complexity of child components inside touchables to keep frame rates at 60fps.
  • Avoid nesting multiple touchables inside each other to prevent gesture conflicts and extra rendering.
  • Use shouldComponentUpdate or React.memo to prevent unnecessary re-renders of touchable components.
  • Prefer TouchableOpacity over TouchableHighlight when you want smooth animations and less abrupt visual changes.
App Bundle Size and Startup Time

Both TouchableOpacity and TouchableHighlight are part of React Native core and add no extra bundle size. They do not affect startup time significantly.

However, if you add many custom styles or images inside these components, that can increase bundle size and slow startup.

iOS vs Android Differences

On iOS, TouchableOpacity uses native opacity animations that are very smooth and consistent with iOS design guidelines.

On Android, opacity animations are also smooth but may feel slightly different due to platform rendering differences.

TouchableHighlight on iOS uses native highlight colors that match the platform style, while on Android it does not use ripple effects by default; instead, TouchableNativeFeedback provides ripple effects.

For Android, consider using TouchableNativeFeedback for ripple effects instead of TouchableHighlight for a more native feel.

Store Review Guidelines
  • Ensure touchable components provide clear visual feedback to meet accessibility guidelines (Apple HIG and Google Material Design).
  • Maintain minimum touch target size (44x44 points on iOS, 48x48 dp on Android) for usability and store compliance.
  • Do not block or delay touch feedback; slow or unresponsive touchables can cause app rejection.
  • Use accessible roles and labels for screen readers to improve app accessibility compliance.
Self-Check: Slow Screen Load

If your app takes 5 seconds to load a screen with touchables, likely issues include:

  • Too many nested or complex child components inside TouchableOpacity or TouchableHighlight.
  • Heavy animations or expensive style calculations on touch feedback.
  • Unoptimized re-renders causing repeated layout calculations.
  • Using TouchableHighlight with complex backgrounds causing slow color transitions.

Check your component tree and optimize by simplifying children, using React.memo, and preferring TouchableOpacity for smoother animations.

Key Result
TouchableOpacity and TouchableHighlight provide essential touch feedback with minimal performance cost. Use TouchableOpacity for smooth opacity animations and better frame rates. Avoid complex nested children to keep UI responsive. Both have no impact on bundle size but follow platform-specific guidelines for best user experience and store approval.