Module 5 of 7

React Performance

"There's nothing faster than not doing anything at all." Most React performance work is making React skip work it can prove is unnecessary, and React's proof is almost always Object.is: the same element, the same props, the same context value. When work can't be skipped, the other options are to make it interruptible (concurrent rendering), load less of it (code splitting), move it off the main thread (Web Workers), or do less of it (windowing).

The notes, in the order to read them:

Every number here (render lists, render counts, milliseconds to the next frame, rows in the DOM) was recorded by running the product store in Chrome (examples/product-store/src/lessons/performance). Timings come from one machine and vary between runs; compare them with each other, not with your own app.

Measure before and after. The React DevTools Profiler ("Highlight updates when components render") and the browser's Performance panel show where time actually goes, and profile a production build: development React does extra work.

Start with “Element Optimization”All notesInterview questions

The notes

Read them in order. Each one builds on the ones before it.

01Must know

Element Optimization

Hand React the same element, or props that compare equal, and it skips the render: reuse, element props, useMemo and memo.

Read
02Must know

Optimize Context

Memoize the value, move state into a provider component, split state from setters: who re-renders after each.

Read
03Must know

Concurrent Rendering

useDeferredValue + memo keeps typing instant over a slow grid; without memo it does nothing (recorded).

Read
04Good to know

Code Splitting

lazy and Suspense load a feature’s code on demand; prefetch on hover; a transition avoids the fallback.

Read
05Good to know

Expensive Calculations

Measure, cache with useMemo, or move the work to a Web Worker and read the result with use.

Read
06Must know

Optimize Rendering

memo on 500 list rows, why one changing prop defeats it, and fixing that with a comparator or primitive props.

Read
07Good to know

Windowing

Render only the visible rows of a 10,000-item list with @tanstack/react-virtual.

Read