Should I use useState or class state for new React code?
useState in functional components for all new code. Understand class state only to read existing code and answer interview questions. Class components are legacy for new development.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in useState vs Class Component State: What's Different?
Class state lived in a single this.state object updated with this.setState, which merged new fields. useState gives separate variables and setters, and updating replaces the value rather than merging, so you spread objects manually.
No. this.setState merges new fields into the existing state object. useState replaces the value entirely. So when storing an object in useState, you must spread the old fields manually to preserve them.
It encourages small, focused state variables that are easier to reason about, removes the confusing this keyword and its binding issues, and lets you organize related logic in custom hooks instead of splitting it across lifecycle methods.
Still have questions?
Browse all our FAQs or reach out to our support team
