AI Hints
Home›React Tutorial›Quality
React · Lesson 79 of 120

Performance

Finding slow renders.

⏱ 2 min read▶ Video at 1:06:41🎓 Free
Watch this lesson in the React courseWatch on YouTube ↗Full React course

React is fast by default. When an app does feel slow, don't guess. Measure first, find the component that's actually slow, and fix just that.

  • Fast by default
  • Don't guess
  • Measure first

The performance loop

Measure with the profiler. Find the slow component. Apply one fix. Then measure again, to prove it helped.

  1. Measure
  2. Find
  3. Fix
  4. Measure again

React DevTools Profiler

Install the React developer tools browser extension. The profiler tab records a session, and shows every render, and how long each component took. Highlight updates shows which parts of the page re-render as you use it.

keyvalue
InstallReact DevTools
Profilerrecords renders
Showstime per component
Highlightwhat re-renders

Common fixes

Move state down, closer to where it's used, so less re-renders. Use memo for genuinely slow calculations. Show long lists in pages, or with a virtual list. And load big parts later, with lazy.

ProblemFix
Too much re-rendersmove state down
Slow calculationuseMemo
Huge listpaginate or virtualize
Big bundlelazy()

Summary

Measure with the profiler, fix the slowest part, and measure again. Next, accessibility.

Key takeaways
  • Profiler
  • One fix
  • Measure again
Next up: Accessibility — labels and roles