Learn how useState works in React, how to manage local component state, and avoid common mistakes beginners make.

Abdur Razzak
Full-Stack Web Developer
useState is a React Hook that lets you add state to functional components. Before Hooks, only class components could hold state. Today, useState is the standard way to manage simple local state in any React component.
You call useState with an initial value and it returns an array with two items: the current state value and a setter function. For example: const [count, setCount] = useState(0). Every time you call the setter, React re-renders the component with the new value.
One frequent mistake is mutating state directly instead of using the setter. Another is forgetting that state updates are asynchronous — you should never read the updated state immediately after calling the setter in the same render cycle. Use the functional update form (prev => prev + 1) when the new state depends on the old one.
useState is perfect for simple, independent pieces of state like toggles, form inputs, or counters. When state logic grows complex or multiple sub-values are related, consider switching to useReducer for clearer, more predictable updates.