Skip to content
tezvyn:

Prefer multiple useState or useReducer for multi-field forms?

Source: react.devMediumHow cards are made

Prefer multiple useState or useReducer for multi-field forms?
Summary

Matching state structure to complexity.

Key points

Separate useState for simple fields; one object for coupled validation or batch resets; useReducer for complex logic.

Watch out for

Picking one pattern for all forms without discussing coupling.

What's really being asked

This question tests whether you can match state architecture to actual UI complexity rather than relying on habit. Interviewers want to see that you understand the trade-offs between colocation, readability, and predictable updates. The core signal is your ability to explain when useState becomes a liability and why useReducer adds value beyond syntax preference.

The full answer

A strong answer presents a clear escalation ladder. First, for two or three independent fields like a search box and a toggle, separate useState hooks are fine because each setter is isolated and the logic stays trivial. Second, when fields are related, such as a shipping form where city, state, and zip must validate together or reset as a unit, a single state object reduces stale state bugs and makes batch updates atomic. Third, when the form grows interdependent logic, like a multi-step wizard where selecting a country changes available provinces, enables VAT fields, and triggers async tax lookups, useReducer becomes the better tool because it centralizes transition logic into a pure reducer function. The dispatch function from useReducer has a stable identity, which helps when passing it into effects or callbacks without dependency headaches. You should also mention that useReducer does not inherently improve performance; it improves predictability.

The mistakes people make

A red flag is insisting that useReducer is always superior for forms because it is more advanced or performant. Another mistake is claiming that multiple useState hooks cause extra re-renders compared to a single object; in React, state updates still trigger a re-render of the component regardless of how many hooks you have. Some candidates also forget to discuss the initializer function or lazy initialization with useReducer, which matters when deriving initial state from props or computing expensive defaults. Finally, avoid suggesting useReducer for a two-field login form unless you can articulate a specific reason, like shared validation logic or action replay.

What usually comes next

An interviewer might ask how you would handle derived state, such as whether a total price should live in reducer state or be computed during render. They may also probe how you would reset the form to its initial state, which is cleaner with useReducer because you can dispatch a RESET action or reinitialize. Another common follow-up is how you would persist draft state to localStorage; here, a reducer can centralize side-effect coordination or you might reach for a custom hook. You might also be asked how React Hook Form or similar libraries change the equation.

A concrete example

Imagine a checkout form with email, shipping address, and billing address fields, plus a checkbox for same-as-shipping. With separate useState hooks, checking the box would require manually copying shipping values into billing and keeping them in sync, which is fragile. With a single object and useReducer, you dispatch a SYNC_BILLING action that derives the next billing state from the current shipping state inside the reducer, making the relationship explicit and testable. If the user later unchecks the box, the reducer can restore the previously independent billing values or clear them based on a single action type.

Interview question

Which scenario most clearly justifies using useReducer instead of useState for React form state?

  • a.Any form with more than five fields to batch updates and improve rendering performance
  • b.A search page with an independent keyword input and sort toggle
  • c.A multi-step wizard where country selection changes provinces, enables VAT, and triggers async tax lookupsCorrect
  • d.A shipping form where city, state, and zip validate together and reset as a unit
Why?

The wizard's cascading interdependencies and async transitions are best centralized in a pure reducer; option D describes coupled fields appropriately managed by a single object with useState, not useReducer.

Just read this? Test yourself on what you have been reading.

Read the original → react.dev

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on react — each one lists the topics its interview covers.

See open roles