REACT Contents

Performance Optimization Playbook

Optimize only after measurement. Learn profiling workflow, render root cause isolation, state scoping rules, and incident triage steps that prevent premature optimization and hidden regressions.

On this page

Performance Philosophy

  • Measure before optimizing.
  • Fix root causes, not symptoms.
  • Optimize state boundaries before adding memoization.

Primary Cost Drivers

  • Unstable props causing wide rerenders.
  • State placed too high in the tree.
  • Context value churn.
  • Large lists without virtualization.
  • Expensive computations in render.

Profiling Workflow

  • Use React DevTools Profiler to identify slow commits.
  • Record interaction trace and inspect component flame graph.
  • Check which components rerender and why.
  • Verify if rerender is necessary or accidental.

Isolation Pattern

  • Move state down to the nearest common parent.
  • Split components by responsibility.
  • Introduce memo boundaries only after state scoping is correct.

Large List Strategy

  • Use virtualization for lists above visible viewport size.
  • Ensure stable keys.
  • Avoid inline object creation in list items.

Failure Modes

  • Premature memo usage masking architectural problems.
  • Context updates triggering entire app rerenders.
  • Derived state stored instead of computed.
  • Async effects triggering state loops.

Incident Triage Checklist

  • Which component commits are slow?
  • Which props changed and why?
  • Is state scoped too high?
  • Are memo boundaries placed correctly?
  • Is heavy computation happening during render?