Lesson 4 of 9 · 27m
Performance Is a User Experience, Not a Benchmark
Measure startup, frame health, memory, network, and interaction latency on real devices — then optimize the path users actually feel.
Most React Native performance work starts too late: after a product manager notices frozen scrolling, reviews mention battery drain, or an Android device in the support queue takes nine seconds to open the home screen. By then the code has accumulated innocent-looking abstraction. Good mobile performance is not one trick. It is latency discipline applied to startup, rendering, networking, images, memory, and input.
Measure the paths users feel
Define performance around user events:
cold start to first interactive frame
login submit to authenticated home
tab switch to visible content
list scroll frame stability
keyboard open latency
background restore correctness
memory growth over a long sessionA synthetic benchmark is useful for regression detection, but users experience flows. Instrument those flows and compare release builds on representative low-end hardware.
JavaScript is single-threaded enough to hurt you
JSON parsing, date formatting, cryptographic work, filtering, sorting, and huge object cloning are common offenders:
const rows = useMemo(() => normalizeOrders(rawOrders), [rawOrders])Memoization helps, but it is not magic. If normalizeOrders transforms 20,000 rows every time the input identity changes, the cost remains. Move large transformations into pagination, incremental computation, native modules, or worker-like isolation where appropriate.
Rendering discipline beats clever hacks
FlatList exists because rendering hundreds of rows naively destroys memory and frame time. Configure it deliberately:
<FlatList
data={orders}
keyExtractor={(item) => item.id}
renderItem={renderOrder}
initialNumToRender={12}
maxToRenderPerBatch={12}
windowSize={7}
getItemLayout={(data, index) => ({length: 72, offset: 72 * index, index})}
/>getItemLayout is powerful only when row height is stable. Fake precision hurts more than it helps. Profile before tuning because these knobs trade memory, blanking, and CPU.
Images and startup are silent budgets
A 4 MB image displayed in a 90-pixel avatar still costs decode memory. Resize server-side, use cache-aware URLs, and avoid base64 image payloads in state. Startup is also a dependency graph problem: analytics SDKs, translations, icon bundles, and validation schemas imported at module scope may execute before the first screen.
Use the right profiler. React DevTools reveals render frequency; Android Studio Profiler and Instruments reveal CPU, memory, image decoding, and native pressure. adb shell dumpsys gfxinfo com.example.app framestats is a quick frame-health starting point.
Field notes
- Debug mode performance is not representative; always validate with release builds.
- Low-end Android matters even if your executive team carries flagship iPhones.
- Re-renders are not automatically bad; expensive renders and unnecessary native work are bad.
- A 60 fps average can hide dropped frames exactly during the interaction users care about.
Was this lesson helpful?