Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 38 ยท Testing and Performance

List and Render Performance

Make an Expo app feel fast: tune FlatList and FlashList, stop needless re-renders with memo and useCallback, keep the JS thread free, optimize images and start-up time.

A phone has a small battery, modest memory and a screen that must redraw 60 or even 120 times per second. If your code takes too long between two frames, the user sees a stutter. Most slow Expo apps share the same few causes: long lists that render too many rows, components that re-render for no reason, heavy work on the JavaScript thread, and big images.

This lesson gives you a short list of tools for each cause, plus a way to measure first. Never optimize without measuring; the slow part is rarely where you guess.

What runs on this site. Rendering and frame rates need a device, so the real component code is read-only. The runnable examples are stand-ins in Node.js: counting renders of memoized functions, computing which rows a list window renders, and chunking a heavy job.

Two threads

React Native runs your JavaScript on one thread (JS thread) and draws the UI on another (UI thread). Touches and animations on the UI thread stay smooth only while the JS thread answers quickly. If your JS spends 300 ms filtering 50,000 items, taps feel dead for 300 ms. Everything below is about keeping the JS thread short of work.

Use the right list

ScrollView renders all its children immediately. Fine for a settings page, terrible for 500 rows. FlatList renders only the rows near the screen (windowing) and recycles memory:

JSX
<FlatList
  data={items}
  keyExtractor={(item) => item.id}
  renderItem={({ item }) => <Row item={item} onPress={openItem} />}
  initialNumToRender={10}
  windowSize={7}
  removeClippedSubviews
  ListEmptyComponent={<Text>Nothing here yet</Text>}
/>

Rules for a fast FlatList:

  1. Stable keys. Use a real id, not the array index, when rows can be reordered or inserted.
  2. Light rows. renderItem runs for every visible row. Keep it small, with no heavy calculations inside.
  3. Fixed heights let you provide getItemLayout={(_, i) => ({ length: 72, offset: 72 * i, index: i })}, so scrolling to an index needs no measurement.
  4. Do not create new objects each render for props like extraData, styles or callbacks; see the next section.
  5. Paginate: use onEndReached to load pages instead of fetching 10,000 rows.

For very large or complex lists, @shopify/flash-list is a drop-in replacement (FlashList) that recycles row components like native lists do. In FlashList v2 you mostly just swap the component and drop most manual tuning; v1 asks for an estimatedItemSize. Check the version you install.

Node.js How windowing saves work

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Stop needless re-renders

When a parent re-renders, all its children re-render, even if their props are identical. For a row inside a list, that multiplies. React.memo skips a component when its props are shallowly equal, but only if you pass stable props. Inline functions and objects are new on every render and defeat memo, so wrap them in useCallback and useMemo:

JSX
const Row = memo(function Row({ item, onPress }) {
  return (
    <Pressable onPress={() => onPress(item.id)}>
      <Text>{item.title}</Text>
    </Pressable>
  );
});

function List({ items }) {
  const [selected, setSelected] = useState(null);
  const openItem = useCallback((id) => setSelected(id), []);   // same function each render
  return <FlatList data={items} renderItem={({ item }) => <Row item={item} onPress={openItem} />} />;
}

The new React Compiler (opt-in with experiments.reactCompiler in app config in recent SDKs) can add this memoization for you automatically, but understanding it still helps you read profiler output.

Node.js Why a new function breaks memo

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Do not wrap everything in memo. Comparing props costs too. Use it on list rows, expensive components and anything that receives frequent parent updates.

Keep heavy work off the JS thread

  • Derived data: compute with useMemo instead of every render.
  • Big loops: split into chunks and yield, or move to a native module or worker.
  • Animations: use react-native-reanimated, which runs animations on the UI thread, instead of animating through React state.
  • Interactions: InteractionManager.runAfterInteractions postpones work until a transition finishes.
  • Debounce search boxes so you filter after typing pauses, not on every key.
Node.js Chunk a heavy job so input stays responsive

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Images

Images are the biggest memory consumers:

  • Use expo-image (caching, contentFit, blurhash placeholders, transitions) instead of the core Image for remote pictures.
  • Serve images at display size: do not download a 4000 px photo for a 100 px avatar. Ask your CDN for resized versions.
  • Prefer WebP/AVIF over PNG for photos; use SVG or icon fonts for icons.
  • Set an explicit width and height so layout does not jump.

Start-up time

Users judge your app in the first two seconds.

  • Keep the splash screen until fonts and initial data are ready (expo-splash-screen), then hide it once.
  • Import heavy libraries only where used. With Expo Router, each route is its own module, and async routes are available for lazy loading.
  • Use the Hermes engine (default); it precompiles JavaScript to bytecode so start-up is faster.
  • Remove unused packages: run npx expo-doctor and look at bundle size with npx expo export and a visualizer such as Expo Atlas (EXPO_ATLAS=1 npx expo start).
  • Do not block the first render on network calls; show cached data first.

Measure first

flowchart LR
  A["Notice it feels slow"] --> B["Measure<br/>(profiler, FPS monitor)"]
  B --> C["Find the biggest cost"]
  C --> D["Fix one thing"]
  D --> E["Measure again"]
  E --> C

Change one thing at a time and re-measure; otherwise you will not know what helped.

Test performance on a release build and a mid-range Android phone. Development mode adds checks that make everything slower, and a flagship iPhone hides problems.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is FlatList faster than ScrollView for long lists?

    Windowing keeps the number of mounted rows small, independent of data size.
  2. 2. Why does passing onPress={() => ...} inline to a memoized row defeat memo?

    memo compares props shallowly; a new function identity counts as a change.
  3. 3. Which thread must stay free for smooth touch response?

    Long JS work delays handling of events and updates.
  4. 4. Where should you measure performance?

    Dev mode is slower than release, and fast hardware hides issues real users have.

Summary

  • Keep the JS thread free; the UI thread draws while JS responds.
  • Use FlatList or FlashList with stable keys, light rows and pagination.
  • Memoize rows and give them stable props via useCallback and useMemo.
  • Move or chunk heavy work, animate with Reanimated, and debounce input.
  • Size and cache images, speed up start-up, and always measure on release builds first.

Next: Debugging and profiling