Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

FlatList Performance Optimization in React Native

FlatList Performance Optimization

~16 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026

FlatList is ITSELF already a virtualization tool (see "React for Professionals" chapter 32 for the basic principle: render only visible entries plus a buffer) – but the default settings are a compromise, not an optimum. This chapter shows how to tune ProductListScreen's FlatList for our specific use case.

Applying React.memo to ProductCard

Just like "React for Professionals" chapter 31 – the first, most important step:

// In components/ProductCard.js, right at the end:
import { memo } from 'react';
// ... component as before ...
export default memo(ProductCard);

Achtung: EXACTLY like the web version, memo() alone is NOT enough: onPress={{() => navigation.navigate(...)}} and onToggleFavorite={{() => dispatch(toggleFavorite(item.sku))}} in ProductListScreen's renderItem are inline functions re-created on EVERY render. The "real" fix (analogous to "React for Professionals" chapter 31, useCallback plus restructuring so ProductCard knows sku/item itself) remains an exercise for you – this chapter focuses on the FlatList-SPECIFIC optimizations.

getItemLayout: skipping layout calculation

By default, FlatList has to RENDER every item first to know its height before it can correctly compute scroll position – with a FIXED item height (our ProductCard always has a 60px image plus fixed padding, so a known total height), you can skip that:

// In screens/ProductListScreen.js:
const ITEM_HEIGHT = 84; // 60px image + 2×12px padding

<FlatList
  data={filteredProducts}
  keyExtractor={(item) => item.sku}
  getItemLayout={(data, index) => ({
    length: ITEM_HEIGHT,
    offset: ITEM_HEIGHT * index,
    index,
  })}
  renderItem={/* ... as before ... */}
/>

getItemLayout tells FlatList every item's position/height IN ADVANCE, via a simple calculation instead of actual rendering – enables instant jumps to any scroll position (e.g. a programmatic scrollToIndex) and noticeably speeds up the initial layout calculation.

More dials: windowSize, maxToRenderPerBatch, removeClippedSubviews

<FlatList
  /* ... existing props ... */
  windowSize={5}              // default: 21 (10 screens before/after the visible area)
  maxToRenderPerBatch={10}    // how many items get processed per render batch
  updateCellsBatchingPeriod={50} // milliseconds between batches
  removeClippedSubviews={true}   // fully removes off-screen native views
/>
  • windowSize: a multiple of the screen height pre-rendered BEFORE and AFTER the visible area – smaller values save memory/compute but risk visible "pop-in" on very fast scrolling.
  • maxToRenderPerBatch + updateCellsBatchingPeriod together control how "chunked" rendering is – smaller batches keep the app more responsive but lengthen the time until all visible items are fully rendered.
  • removeClippedSubviews: on ANDROID, fully removes scrolled-off items from the native view tree (not just made "invisible") – historically less reliable on iOS, test on BOTH platforms before using it.

Achtung: These props are NOT "always faster" switches – they shift a trade-off between memory usage, render time, and scroll smoothness. For our 6-products-per-page list (pagination, similar to "React for Beginners"), the defaults are already more than sufficient – these optimizations only pay off with HUNDREDS of simultaneously loaded items. Use the profiler from the last chapter to verify a change actually helps, instead of blindly guessing values.

Bonus: FlashList as a drop-in replacement

Shopify's @shopify/flash-list is a performance-optimized FlatList alternative with an almost identical API (often just a simple import swap) – internally uses cell recycling (existing native views get reused instead of destroyed/recreated) instead of a fresh mount for every scrolled item. For very long lists (hundreds/thousands of entries, see the "order history" virtualization from "React for Professionals" chapter 32), often the better choice over pure FlatList tuning.

npx expo install @shopify/flash-list

Tipp: Rule of thumb: getItemLayout is ALWAYS worth it when you have a fixed item height (costs almost nothing, always helps a bit). windowSize/maxToRenderPerBatch tuning only once you've actually MEASURED scroll problems. Consider FlashList only for TRULY long lists – for our small product list it would be overengineering.