Skip to main content

Optimizing FlatList Performance

Learn how to optimize FlatList for smooth 60 FPS scrolling, even with large datasets. FlatList is React Native’s high-performance list component that virtualizes content.

How FlatList Works

FlatList uses VirtualizedList under the hood to:
  1. Render only visible items: Items outside viewport are unmounted
  2. Recycle components: Reuse components as you scroll
  3. Batch updates: Group multiple updates for efficiency
  4. Windowing: Keep a buffer of items above and below viewport

Basic FlatList Setup

Essential Optimizations

1. Implement getItemLayout

Prevent expensive layout calculations by providing item dimensions:
Benefits:
  • No layout measurements needed
  • Instant scroll position calculation
  • Smooth scrollToIndex behavior
Note: Only use if all items have the same height.

2. Use keyExtractor Correctly

Provide stable, unique keys:

3. Optimize renderItem with React.memo

Prevent unnecessary re-renders:

4. Configure Window Size

Control how many items to keep mounted:
Parameter Guide:
  • initialNumToRender: First batch size (default: 10)
  • maxToRenderPerBatch: Items per subsequent batch (default: 10)
  • windowSize: Screen lengths to keep mounted (default: 21)
  • Lower values = less memory, more blank content during fast scrolling

5. Remove Clipped Subviews

Unmount off-screen components (Android primarily):
Benefits:
  • Reduced memory usage
  • Better performance on Android
Caveats:
  • May cause issues with animations
  • Can have bugs with complex layouts

Advanced Optimizations

Avoid Anonymous Functions

Optimize Images

Use ListEmptyComponent

Implement Pull to Refresh

Infinite Scroll

Measuring Performance

Monitor Render Times

Track Scroll Performance

Common Performance Issues

Issue 1: Slow Scrolling

Symptoms: Choppy scrolling, frame drops Solutions:
  • Implement getItemLayout
  • Reduce windowSize
  • Optimize renderItem with React.memo
  • Avoid heavy computations in render

Issue 2: Blank Content While Scrolling

Symptoms: White space during fast scrolling Solutions:
  • Increase initialNumToRender
  • Increase maxToRenderPerBatch
  • Increase windowSize

Issue 3: Memory Issues

Symptoms: App crashes with large lists Solutions:
  • Decrease windowSize
  • Enable removeClippedSubviews
  • Optimize images (compress, use thumbnails)
  • Implement pagination

Issue 4: Incorrect Item Updates

Symptoms: Wrong items update or display Solutions:
  • Use stable keyExtractor
  • Implement proper extraData prop

FlatList vs SectionList

Use SectionList for grouped data:
Both support the same optimization props.

Testing Performance

Create Test Data

Benchmark Configurations

Best Practices Checklist

  • Use stable keyExtractor (not index)
  • Implement getItemLayout for fixed-height items
  • Wrap items with React.memo
  • Use useCallback for event handlers
  • Configure initialNumToRender, maxToRenderPerBatch, windowSize
  • Enable removeClippedSubviews on Android
  • Optimize images (size, caching, loading)
  • Avoid anonymous functions in props
  • Profile and measure performance
  • Test on low-end devices

Next Steps