React useState hell is what happens when one component juggles so many separate useState calls that every change touches several setters. The fix is to group, derive or reduce that state.
This guide is for React developers with too many useState hooks in one component. You get six fixes with short code examples and a clear rule for when to switch.
BOSC Tech Labs has built web and mobile products for clients since 2019, and our engineers often take over React codebases another team started. This guide follows the state problems we fix most in those handovers.
The fixes run from the lightest change to the heaviest, so start at the top and stop as soon as your component is easy to read again.
For the wider picture of local, shared and global state, see our complete guide to React state management.
Key takeaways
- Group values that always change together, and calculate anything you can instead of storing it.
- Switch to useReducer when one value depends on another; that rule settles most useReducer vs useState questions.
- Custom hooks share logic between components, while Context shares the actual state.
- Reach for a state library only when many distant components update the same data often.
What is React useState hell?
React useState hell describes a component with many separate useState calls whose values depend on each other. Updates scatter across handlers, so bugs appear when one setter runs and another is forgotten.
It rarely starts that way. A form begins with two fields, then gains validation, a loading flag, an error message and a success banner, each added as one more useState call.
The worst result is an impossible state. Nothing stops isLoading and error from both holding values, so the screen can show a spinner and an error message at the same time.
Here is a typical event registration form after a few months of growth:
function EventForm() {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [ticketType, setTicketType] = useState('standard');
const [quantity, setQuantity] = useState(1);
const [total, setTotal] = useState(0);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
const [isSuccess, setIsSuccess] = useState(false);
// ...handlers that call three or four setters each
}
5 signs your component has too many useState hooks
You can spot tangled component state by checking five things in your own code. If two or more of these signs apply to one component, refactor it before you add another setter.
- One user action calls three or more setters, such as setIsLoading, setError and setIsSuccess inside the same click handler.
- A useEffect exists only to copy or recalculate one state value from another, like updating total whenever quantity changes.
- Two flags can contradict each other, such as isLoading and isSuccess both being true after a fast double click.
- You pass a value and its setter down two or more component layers that never read them.
- Typing in one field re-renders a large part of the screen, which the Profiler in React DevTools makes easy to see.
When our team reviews a React component, the first thing we check is how many setters fire on one user action. If a single click calls three or four of them, that state usually belongs together.
None of these signs means the code is wrong. They mean the component has outgrown its first design, which is how React useState hell usually begins.
Count the signs for your worst component now. The number tells you how far down the list of fixes you will need to go.
How to fix React useState hell: 6 fixes with code
You can fix React useState hell in six steps, from least to most effort: group related values, calculate what you can, move connected updates into useReducer, extract a custom hook, then share state only where needed.
The table maps each symptom to the lightest fix that solves it.
| Symptom | Fix | React tool |
|---|---|---|
| Several values always change together | Fix 1: group them | One useState object |
| A useEffect copies one state into another | Fix 2: calculate during render | Plain variables or useMemo |
| One action needs several setters and rules | Fix 3: centralise updates | useReducer |
| The same state logic repeats in several components | Fix 4: extract it | A custom hook |
| Props pass through layers that never read them | Fix 5: share through a provider | createContext and useContext |
| Many distant components update the same data often | Fix 6: move it to a store | An external state library |
Work down the table and stop at the first fix that removes the problem. Most components need only Fix 1 to Fix 3.
Fix 1: Group values that change together
The cheapest way to cut too many useState calls is to merge values that are always set at the same time. Name, email, ticket type and quantity are all form fields, so one object can hold them.
const [form, setForm] = useState({
name: '',
email: '',
ticketType: 'standard',
quantity: 1,
});
function handleChange(e) {
const { name, value } = e.target;
setForm(prev => ({ ...prev, [name]: value }));
}
One handler now updates any field. Spread the previous object so the other fields survive each update; for deeply nested objects, Immer removes most of that copying.
Long forms with validation often outgrow a single object. Fix 3 shows how a reducer keeps field values, errors and submit status in step.
Fix 2: Calculate instead of storing
If a value can be computed from props or other state, do not store it. This is derived state, and the React docs advise against keeping it in useState because the copy can drift out of sync.
// Before: extra state kept in sync by an effect
const [total, setTotal] = useState(0);
useEffect(() => {
setTotal(form.quantity * prices[form.ticketType]);
}, [form.quantity, form.ticketType]);
// After: calculated during render
const total = form.quantity * prices[form.ticketType];
One state value and one effect disappear, and total can never be stale. Wrap the calculation in useMemo only if it is genuinely expensive.
Fix 3: Move connected updates into useReducer
When one event must update several values by fixed rules, put those rules in a reducer. The component dispatches a named action, and the reducer returns the whole next state in one step.
function submitReducer(state, action) {
switch (action.type) {
case 'submit': return { status: 'loading', error: null };
case 'success': return { status: 'success', error: null };
case 'failure': return { status: 'error', error: action.error };
default: return state;
}
}
const initial = { status: 'idle', error: null };
const [submit, dispatch] = useReducer(submitReducer, initial);
One status field replaces three booleans, so loading and success can no longer be true together. Each change is now one dispatch call instead of three separate setters.
On long multi-step forms we build for clients, we usually move field values, errors and submit status into one reducer. Code review gets simpler, because every state change has a named action you can search for.
Fix 4: Extract a custom hook
If several components repeat the same state logic, move it into a custom hook. A custom hook is a function whose name starts with use and that calls other hooks inside it.
function useToggle(initial = false) {
const [isOn, setIsOn] = useState(initial);
const toggle = useCallback(() => setIsOn(v => !v), []);
return [isOn, toggle];
}
// In any component
const [isMenuOpen, toggleMenu] = useToggle();
Each component that calls useToggle gets its own separate state. Custom hooks share logic, not data, which is the most common mix-up with Context.
Fix 5: Share state with Context instead of passing props
When a value travels through layers that never use it, that is prop drilling. The Context API lets any child read the value directly from a provider placed higher in the tree.
const CartContext = createContext(null);
function App() {
const [cart, dispatch] = useReducer(cartReducer, []);
return (
<CartContext.Provider value={{ cart, dispatch }}>
<Checkout />
</CartContext.Provider>
);
}
// In any child: const { cart } = useContext(CartContext);
The React docs pair a reducer with Context for exactly this case. Every component that reads the context re-renders when its value changes, so keep fast-changing data out of broad providers.
Fix 6: Use Zustand or Redux Toolkit for app-wide state
A state library makes sense when many distant components read and update the same data often. Zustand suits small and medium apps, while Redux Toolkit adds stricter structure and strong debugging tools.
For a single form or page, a library adds setup without curing the useState hook hell inside it. Before you pick one, read our overview of React state management libraries.
useReducer vs useState: which one should you use?
In the useReducer vs useState choice, keep useState for independent values like a toggle or one input. Switch to useReducer when the next state depends on other state or on several fields at once.
The table compares the two hooks in the situations you meet most often.
| Situation | useState | useReducer |
|---|---|---|
| One independent value | Best fit | Adds code without benefit |
| Several values updated by one event | One setter per value, easy to miss one | One dispatch updates all |
| Next value depends on other state | Logic spread over handlers | Rules in one reducer function |
| Testing the update logic | Needs the component rendered | The reducer is a pure function you can test alone |
| Passing updates to child components | Several setters to pass down | One dispatch function to pass down |
If most rows point to useReducer for your component, the switch will pay for itself quickly.
We do not convert every component to a reducer. Our rule in code review is simple: if the next value depends on another piece of state, we use a reducer; if it is a lone toggle or input, plain useState stays.
Neither hook is faster by default. Both re-render the component when state changes. A reducer brings clearer logic, easier tests and a dispatch function that keeps the same identity between renders.
That stable dispatch is useful when you pass it to memoized children, because it never breaks their memoization the way a new inline callback can.
When you do switch, keep the reducer pure: no API calls, timers or random values inside it. The same state and action should always return the same result.
When useState is still the right choice
Plain useState is still right for values that change on their own, like a modal flag, a search input or a selected tab. Three unrelated toggles in one component are not a problem worth refactoring.
Having too many useState hooks is about relationships, not numbers. Ten independent values can be fine, while three values that must always change together are already a warning sign.
Refactoring too early has a cost. Wrapping a lone boolean in a reducer adds a switch statement, action names and indirection that the next developer has to read for no gain.
So treat React useState hell as a design signal, not a rule to apply everywhere. Fix the components that show the signs above and leave the simple ones alone.
When to bring in React consultants
Outside help makes sense when state problems span many components, slow down every release or block an upgrade, and your team has no time to untangle them alongside feature work.
Most teams that ask us for help do not need a rewrite. We start with a short review of the worst components, fix one together with your developers, and leave a pattern your team can repeat.
Typical signs it is time: the same bugs return after each fix, new developers take weeks to understand core screens, or a planned move to React 19 keeps slipping.
If you need extra hands for that work, you can hire dedicated React developers from our team.
Frequently asked questions
How many useState hooks is too many?
There is no fixed number. The real signal is related values that always change together, or values you keep in sync with useEffect. Independent values can stay separate, however many there are.
Is React useState hell a sign of bad code?
Not necessarily. It is a normal stage as a component grows and gains features. It signals that the component needs a refactor, not that someone made a mistake.
Does useReducer improve performance over useState?
Not by itself. Both hooks re-render the component when state changes. The gains are clearer update logic, easy unit tests for the reducer and a stable dispatch function.
Is Context enough, or do I need a state library?
Use the Context API for data a subtree shares that changes rarely, like a theme or the signed-in user. Consider Zustand or Redux Toolkit when many distant components update the same data often.
Can custom hooks share state between components?
No. Each component that calls a custom hook gets its own copy of the state. To share the same data, lift the state up to a common parent, use Context or use a store.
Does React 19 change how I should manage form state?
Yes, for submissions. React 19 Actions, useActionState and useOptimistic handle pending, error and optimistic states, which removes several useState calls. The React Compiler automates memoization but does not restructure your state.
Next steps: refactor one component this week
Pick the component your team dreads touching most. Count how many setters fire for each user action, and note any effect that only copies one state value into another.
Then apply the fixes in order: group, derive, reduce, extract, share. Profile before and after with React DevTools to confirm fewer re-renders and simpler update paths.
One cleaned-up component is the fastest way out of React useState hell, and it gives your team a pattern to copy. If you want a second pair of eyes on yours, our React team can review it with you.



