Skip to main content

Lesson 2 of 10

FlatList Deep Optimization

FlatList is the most performance-critical component in data-heavy apps. Getting it wrong means jank on every scroll. Getting it right means buttery-smooth 60fps even on mid-range Android devices.

30 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

All Performance Props Explained

All Performance Props Explained
// The complete high-performance FlatList configuration:
<FlatList
  data={data}
  keyExtractor={keyExtractor}  // stable, memoized
  renderItem={renderItem}       // stable, memoized

  // ---- Virtualization window ----
  // windowSize: number of "viewport heights" kept in memory
  // Default 21 (10 above + 10 below + current) - reduce to 5 for memory-constrained
  windowSize={5}

  // ---- Initial render ----
  // How many items to render before the first paint (don't set too high - delays TTI)
  initialNumToRender={8}

  // ---- Batch rendering ----
  // How many items each JS batch renders (batches run off the main thread)
  maxToRenderPerBatch={10}

  // ---- Android off-screen unmount ----
  // Unmounts items far outside the scroll window on Android (saves memory on low-end devices)
  // Caution: can cause blank flickers if windowSize is too small
  removeClippedSubviews={Platform.OS === 'android'}

  // ---- Skip layout measurement (BIGGEST win for fixed-height lists) ----
  // Without this: FlatList measures every item before scrollToIndex works
  // With this: FlatList knows positions without measuring
  getItemLayout={(_data, index) => ({
    length: ITEM_HEIGHT,
    offset: ITEM_HEIGHT * index,
    index,
  })}

  // ---- Separator ----
  // Prefer ItemSeparatorComponent over margin in item styles
  // It doesn't render for the last item automatically
  ItemSeparatorComponent={() => <View style={{ height: 12 }} />}

  // ---- Scroll performance ----
  showsVerticalScrollIndicator={false}
  // On Android: this prevents ANR when scrolling quickly
  disableIntervalMomentum

  // ---- Content padding (instead of wrapper View) ----
  contentContainerStyle={{ padding: 16, paddingBottom: 40 }}
/>

// ---- ITEM_HEIGHT calculation ----
// Measure your item in Storybook or Whyframe:
// Avoid fixed height guesses - use onLayout once and cache:

const ITEM_HEIGHT = 120; // header (52) + body (52) + separator (12) + padding (4)

FlashList - When FlatList Still Isn'T Enough

FlashList - When FlatList Still Isn'T Enough
// Shopify's FlashList is a drop-in FlatList replacement
// It reuses item cells (like Android RecyclerView) instead of unmount/remount
// 10x faster than FlatList for complex items

npm install @shopify/flash-list

import { FlashList } from '@shopify/flash-list';

<FlashList
  data={posts}
  renderItem={({ item }) => <PostCard post={item} />}
  estimatedItemSize={120}    // REQUIRED - provide your measured item height
  keyExtractor={p => p.id}
  onEndReached={loadMore}
  onEndReachedThreshold={0.3}
  refreshControl={<RefreshControl refreshing={isRefreshing} onRefresh={refresh} />}
/>

// FlashList advantages:
// - Recycles native views (no unmount/remount → no re-render cost)
// - Content appears instantly (no flash of blank items while mounting)
// - estimatedItemSize enables FlashList to pre-calculate scroll positions

Tip

Tip

Practice FlatList Deep Optimization in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

Maximizing scroll frame rates with getItemLayout, windowSize, and view clipping

Practice Task

Note

Practice Task - (1) Write a working example of FlatList Deep Optimization from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with FlatList Deep Optimization is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready react native code.

Topics in This Module

0/10 done