# React Native Performance Lessons from a Stock Exchange App

> Real-world patterns for building React Native apps that handle hundreds of thousands of investors, real-time data, and zero-tolerance latency requirements.

- Author: Hashan Jayalath, full-stack and AI lead at Allsopp & Allsopp (https://www.hashanj.com/)
- Published: 2025-04-08
- Updated: 2025-04-08
- Reading time: 10 min
- Topics: React Native, mobile performance, stock exchange app, real-time data, fintech mobile, Hermes engine, FlatList optimization
- URL: https://www.hashanj.com/articles/react-native-performance-at-scale

When your React Native app is the primary interface for a national stock exchange, "it feels a bit slow" isn't feedback — it's a P0. Users watching live market data expect sub-second updates, smooth scrolling through thousands of instruments, and instant order execution.

Here's what I learned building and optimizing high-frequency financial apps in React Native.

## Why React Native for Fintech?

The obvious question first. Cross-platform development with React Native let us ship for iOS and Android with a single codebase, which cut our time-to-market roughly in half. But the real advantage was talent density — strong React developers could contribute to mobile immediately.

The trade-off is that performance requires deliberate effort. You don't get native-level performance for free; you earn it through architecture choices.

## The Hermes Advantage

Switching to the Hermes JavaScript engine was the single largest performance win we achieved. On our lower-end Android test devices:

- **App startup time dropped by 40%** — Hermes compiles JS to bytecode at build time instead of runtime
- **Memory usage decreased by 25%** — critical when users leave the app open all day during market hours
- **TTI (Time to Interactive) improved by 1.2 seconds** on mid-range devices

If you're running React Native 0.70+ and haven't enabled Hermes, you're leaving significant performance on the table.

## Real-Time Data Without Jank

Stock prices update every few hundred milliseconds during market hours. Naively pushing every update into React state creates a re-render firestorm that tanks your frame rate.

**Patterns that solved this:**

### 1. Throttled State Updates

Not every price tick needs to trigger a re-render. We throttle updates to 4–5 per second per visible instrument — fast enough to feel real-time, slow enough to maintain 60fps.

```javascript
const throttledPrice = useRef(price);
const frameRef = useRef();

useEffect(() => {
  cancelAnimationFrame(frameRef.current);
  frameRef.current = requestAnimationFrame(() => {
    throttledPrice.current = price;
    forceUpdate();
  });
}, [price]);
```

### 2. Virtualized Lists Done Right

`FlatList` is not enough for lists of 2,000+ instruments. We switched to a custom virtualized implementation that:

- Uses `getItemLayout` with fixed row heights to skip measurement
- Implements `windowSize={5}` to limit off-screen rendering
- Separates the price cell into its own `React.memo` component so row re-renders don't cascade

### 3. Native Bridge Optimization

For the most latency-sensitive operations (order submission, biometric auth), we wrote thin native modules that bypass the JS bridge entirely. The rule of thumb: if latency matters more than code sharing, go native for that specific path.

## Memory Leaks: The Silent Killer

Financial apps are "always on" apps — users open them at market open and close them at market close (if at all). Memory leaks that are invisible in a 5-minute test session become app crashes after 6 hours.

**Our leak-hunting protocol:**

1. **Automated soak tests**: Run the app in a test harness for 8 hours with simulated market data. Monitor heap growth
2. **WebSocket cleanup discipline**: Every `useEffect` that opens a socket returns a cleanup function. No exceptions
3. **Image cache bounds**: Instrument logos and chart images need an eviction policy. We cap the image cache at 50MB and use LRU eviction

## Navigation Performance

Deep navigation stacks (Watchlist → Instrument → Order → Confirmation → Receipt) accumulate screens in memory. React Navigation's default behavior keeps all screens mounted.

**What we do:**

- `unmountOnBlur: true` for screens that don't need to maintain state
- Lazy-load heavy screens (charts, order books) until the user actually navigates to them
- Prefetch the next likely screen during idle time (`InteractionManager.runAfterInteractions`)

## Bundle Size Discipline

Every kilobyte matters for app store ratings, install conversion, and cold start time.

**Our rules:**

- **No moment.js** — use `date-fns` with tree-shaking
- **Audit native dependencies quarterly** — each native module adds to the binary
- **Split non-critical features into dynamic imports** — the settings screen doesn't need to be in the initial bundle
- **Monitor bundle size in CI** — if a PR increases the bundle by more than 50KB, it needs explicit justification

## Measuring What Matters

We track these metrics in production (via custom analytics, not just synthetic tests):

| Metric | Target | Why |
|--------|--------|-----|
| Cold start → interactive | < 2s on P75 devices | First impression; affects retention |
| Price update → UI reflect | < 200ms | Perceived real-time |
| Order submit → confirmation | < 500ms | User confidence in execution |
| Scroll FPS on instrument list | > 55fps | Smoothness perception |
| JS thread utilization | < 60% average | Headroom for spikes |

If you can't measure it in production on real devices, you can't optimize it.

## Key Takeaways

1. **Hermes is non-negotiable** for production React Native apps
2. **Throttle real-time updates** to the visual refresh rate, not the data rate
3. **Memory management is architecture**, not debugging — design for long-running sessions from day one
4. **Profile on the weakest device your users actually have**, not your development machine
5. **Native modules are tools**, not admissions of failure — use them where they matter

---

*Building high-performance mobile applications is one of the challenges I enjoy most. If your team is struggling with React Native performance, [let's talk](https://www.hashanj.com/contact).*
