Course contentsShow
← React
Lesson 1197 of 2,39631. Forms in ReactFree lesson

Performance Implications: Re-renders on Every Keystroke

Analyzing the re-render cost of controlled inputs that update state on each onChange event.

Performance Implications: Re-renders on Every Keystroke

You'll learn: Why controlled inputs trigger component re-renders on every character typed and when this actually matters.

The Re-render Reality

With controlled inputs, every onChange event updates state, and every state update triggers a re-render. Type "hello" and you've caused 5 re-renders—one per letter. This sounds expensive, but React is fast. The virtual DOM diffing for simple inputs is typically negligible.

When It Becomes a Problem

Performance issues arise when:

  • Large component trees: Your form component renders hundreds of child components that don't use memo.
  • Expensive computations: You're running heavy calculations on every render without useMemo.
  • Complex UI updates: Each keystroke animates visualizations, filters large lists, or triggers layout recalculations.

The Typing-in-a-Library Analogy

Imagine rewriting an entire library catalog card every time someone adds a letter to a search box. For a small card (simple component), it's fast. But if that card triggers reprinting every book label in the building (deep component tree), you'll notice the lag. The card-rewriting itself isn't the problem—the cascade is.

What Actually Costs

The real cost isn't the state update—it's:

  1. Reconciliation time for child components
  2. Effect re-runs triggered by changing dependencies
  3. Expensive render logic that should be memoized but isn't

For most forms with a few inputs and minimal children, controlled components perform perfectly fine. The re-render cost is microseconds.

Key Takeaway: Controlled inputs re-render on every keystroke by design, but this rarely causes real performance issues unless your component tree is large, expensive, or poorly optimized. Measure before optimizing.