Mrs. Rini's cashier tablet is starting to feel heavy: buttons answer late when tapped, and the History list stutters as it scrolls. Keeping an app answering touches and scrolling without stutter is what performance optimisation is about. A phone draws at least 60 frames per second, so every frame gets at most 16.67 ms. When the work runs past that, a frame is dropped and the screen feels choppy (jank). At Mrs. Rini's counter, one cashier (the JavaScript thread) serves every request, while the clothes conveyor (the UI thread) keeps moving on its own. When the cashier is busy adding up 5,000 receipts, customers who want to pay wait, even though the conveyor keeps running.
Measure first, then change
| Tool | What for | How to open it |
|---|---|---|
| React Native DevTools, React Profiler tab | which components render and for how long | press j in the npx expo start terminal |
| React Native DevTools, Performance panel | a recording of JavaScript execution | a panel new since React Native 0.83 (SDK 57 uses 0.86) |
| Performance monitor | UI thread and JS thread FPS, right on the phone | developer menu, "Toggle performance monitor" |
| Android Studio Profiler, Xcode Instruments | CPU, memory and system traces on the native side | from Android Studio and Xcode |
- Measure in a release build (
npx expo run:android --variant release,npx expo run:ios --configuration Release). Development mode adds checks that make JavaScript much slower. - Old tutorials say to use Flipper and Systrace. Flipper's integration was deprecated in React Native 0.73 and dropped from the template in 0.74, and the
systracetool has been removed from Android platform-tools. Their replacements are React Native DevTools and the Android Studio profiler (its recordings open in Perfetto). - Lots of
console.logalso slows the JS thread in a release build.
Two threads, one frame
The JavaScript thread runs React, state and requests. The UI thread draws native views and scrolls a ScrollView. The performance monitor shows two FPS numbers, one per thread.
- When the JS thread is busy (say, adding up 5,000 receipts on every render), new taps are handled after it: buttons feel late, and new rows in a fast-scrolled list show up blank first.
- Scrolling and animations running on the UI thread stay smooth. That's why the #13 badge is animated with Reanimated, whose worklets run on the UI thread (animations lesson).
- The most common cause of jank is excessive re-rendering: components that didn't change are computed again every time their parent renders.
Long lists: FlatList
ScrollView + map makes every row at once. FlatList only makes the rows around the screen (virtualisation). Its defaults, checked in React Native 0.86's code:
| Prop | Default | Meaning |
|---|---|---|
initialNumToRender |
10 | rows made in the first render |
maxToRenderPerBatch |
10 | extra rows per turn |
windowSize |
21 | the window = 21 times the screen height: the visible screen plus up to 10 screens above and 10 below |
removeClippedSubviews |
true on Android, false on iOS |
detach views that left the screen from the native hierarchy |
Guess first: the History screen holds a year's 5,000 receipts, each row 72 tall, the list area 640 tall. How many OrderRows does ScrollView + map make, and how many does FlatList make with the defaults above?
For 5,000 receipts, rows of 72, an area of 640: ScrollView makes 5,000 OrderRows before the first screen shows. FlatList makes 10 in the first render, then adds 10 at a time until its window is full. At the very top, the window is 640 + 10 × 640 = 7,040, so about 98 rows, and that number doesn't grow even with 50,000 receipts.
// src/app/history.tsx (cashier mode)
const ROW_HEIGHT = 72; // OrderRow: height 72
export function History({ receipts }: { receipts: Order[] }) {
const open = useCallback((id: string) => router.push(`/order/${id}`), []);
return (
<FlatList
data={receipts}
keyExtractor={(o) => o.id}
renderItem={({ item }) => <OrderRow order={item} onPress={open} />}
getItemLayout={(_, index) => ({ length: ROW_HEIGHT, offset: ROW_HEIGHT * index, index })}
windowSize={11}
/>
);
}
keyExtractor: a stable key per row (the receipt'sid), so React can match old and new rows.getItemLayout: when every row has the same height, FlatList doesn't need to measure each one and can jump straight there. Row 4,000 sits at offset 72 × 3,999 = 287,928.- Without
getItemLayout,scrollToIndex({ index: 3999 })to a row never measured fails withscrollToIndex should be used in conjunction with getItemLayout or onScrollToIndexFailed, otherwise there is no way to know the location of offscreen indices or handle failures. windowSize={11}: a smaller window, less memory, but very fast scrolling can show a blank area for a moment.
Re-renders: memo and React Compiler
When #13 changes to "Ready for pickup", TanStack Query hands out a new array, but the other order objects stay the same objects (structural sharing). Who re-renders depends on two things. First, every FlatList row is wrapped in a cell that is a PureComponent: if its item and renderItem are the same, that cell is skipped. Second, memo(OrderRow) skips a render when all props are equal by Object.is. Counted for the 98 mounted rows, without React Compiler:
renderItem |
OrderRow |
What re-renders |
|---|---|---|
| a new function every render | no memo |
98 rows |
| a new function every render | memo, but onPress={() => open(item.id)} |
98 rows: its props always differ |
| a new function every render | memo, onPress={open} from useCallback |
1 row: #13 |
stable (useCallback) |
anything | 1 row: the other cells are skipped |
- The Expo SDK 57 template turns on React Compiler (
reactCompiler: true), which memoizes components and values automatically, including arenderItemfunction inside a component. React's docs advise relying on the compiler for new code and keeping thememo,useMemoanduseCallbackyou already have. Measure with React Profiler before and after; don't guess. useMemofor heavy calculations used during render, like the total of 5,000 receipts, so they aren't redone on every tap.
FlashList
@shopify/flash-list reuses the views of rows that left the screen instead of throwing them away. npx expo install on SDK 57 installs 2.0.2 (npm already has 2.3.3). Version 2 only runs on the New Architecture, is pure JavaScript (no native code), and no longer needs estimatedItemSize:
import { FlashList } from '@shopify/flash-list';
<FlashList data={receipts} keyExtractor={(o) => o.id} renderItem={({ item }) => <OrderRow order={item} onPress={open} />} />
Because views are reused, images in a row need recyclingKey (see below), so the previous customer's photo doesn't flash for a moment.
Images and app start time
- expo-image:
cachePolicydefaults to'disk'. For photos that show up again and again in a list,'memory-disk'. AddrecyclingKey={order.id}in FlashList, and aplaceholder(blurhash) so there's no empty box. - Bundle size:
npx expo export --platform androidin this project (11 October 2026) gave 1,243 modules and a 2.7 MB Hermes bytecode bundle (2,662,347 bytes). See what's inside withEXPO_ATLAS=true npx expo exportthennpx expo-atlas .expo/atlas.jsonl, and drop libraries you don't need. - Lazy screens: Expo Router's async routes aren't supported in native release builds yet. Hermes also memory-maps the bytecode before running it, so splitting the bundle matters less. What you do feel is the work that runs at start. Don't put heavy calculations or large library imports in
src/app/_layout.tsx.
⚠️ Why is it still slow after optimising?
- Measuring in development mode. The numbers are far worse than in a release build. Measure a release build, on a low-end Android phone, not only on a new iPhone.
ScrollView+mapfor thousands of rows. Every row is made at once. UseFlatListorFlashList.- Inline functions to a
memocomponent. Its props always differ, somemonever skips a render. Pass a stable function. scrollToIndexwithoutgetItemLayout. It fails for rows not measured yet. Fill ingetItemLayoutwhen rows share a height, or handleonScrollToIndexFailed.- Using Flipper or Systrace from old tutorials. Use React Native DevTools and the Android Studio profiler or Instruments.
TL;DR: One frame gets 16.67 ms; the JS thread runs React and logic, the UI thread scrolls and runs Reanimated worklets. Measure first, in a release build: React Native DevTools (React Profiler, the Performance panel since 0.83), "Toggle performance monitor", and Android Studio Profiler and Xcode Instruments; Flipper and Systrace are left behind. The most common cause of jank is excessive re-rendering: a stable renderItem, or memo with stable props (useCallback), means only the #13 row re-renders instead of 98, and React Compiler in SDK 57 memoizes a lot automatically. For 5,000 receipts, ScrollView makes 5,000 rows, FlatList 10 then about 98 (defaults initialNumToRender 10, maxToRenderPerBatch 10, windowSize 21); getItemLayout makes scrollToIndex jumps work, keyExtractor gives stable keys. FlashList 2 (2.0.2 on SDK 57) reuses views, needs the New Architecture, and has no estimatedItemSize. Use expo-image with cachePolicy and recyclingKey, check the bundle (2.7 MB, 1,243 modules in this project) with Expo Atlas, and keep heavy work out of the root layout.
⚡ A 16.67 ms budget
Meaning: A phone draws at least 60 frames per second, so every frame gets at most 16.67 ms. When the work runs past that, a frame is dropped and the screen feels choppy (jank). Measure first in a release build with React Native DevTools and the performance monitor, then change things.
⚡ 5,000 receipts in one list
Guess first: the History screen holds 5,000 receipts, each row 72 tall, the list area 640 tall. How many OrderRows does ScrollView + map make, and how many does FlatList make?
ScrollView makes all 5,000 at once. FlatList makes 10 in the first render, then adds more until its window is full: about 98 at the very top.
Meaning: FlatList only makes the rows around the screen. That 98 doesn't grow, even with 50,000 receipts.
⚡ Excessive re-rendering
Write:
const open = useCallback((id: string) => router.push(`/order/${id}`), []);
<OrderRow order={item} onPress={open} />
Meaning: The most common cause of jank is excessive re-rendering. With memo(OrderRow) and a stable onPress from useCallback, only the #13 row re-renders when #13 changes, not 98. React Compiler in SDK 57 memoizes a lot automatically.