React / 64
Do you need Redux?
Props, Context or Redux? Pick by how many components need the data and how often it changes. Most state never needs Redux.
Give state the smallest home that works
Most state is local, and should stay that way. Move it somewhere bigger only when you have a reason.
1 · used by one component
useState / useReducer
a dropdown's open flag, an input's text2 · used by a parent + a few children
Lift state up, pass props
a filter shared by a list and its toolbar3 · used by many components, changes rarely
Context
theme, logged-in user, language4 · used by many components, changes often
Redux Toolkit (or Zustand)
a cart, an editor document, complex filters
a different kind of state
Data that lives on a server
Menus, orders, profiles: use RTK Query or TanStack Query. They fetch, cache and refresh it for you.
useContext vs Redux
Both let far-apart components share data, so people often compare them. They solve different problems.
Context (useContext) | Redux Toolkit | |
|---|---|---|
| What it is | A way to pass a value down the tree | A store that holds state and controls how it changes |
| Comes with React? | Yes | No: @reduxjs/toolkit + react-redux |
| Where state lives | Still in a useState / useReducer above the provider | In the store, outside your components |
| When the value changes | Every component reading the context re-renders | Only components whose selected piece changed re-render |
| Changing the data | Whatever setter you pass down | Only by dispatching actions to reducers |
| Debugging | React DevTools | Redux DevTools: every action, every diff, time travel |
| Async logic | Write it yourself | Thunks and RTK Query built in |
| Setup | A few lines | A slice, a store and a Provider (still small with Toolkit) |
So Context is a transport, not a state manager. Pair it with useState for data that's read in many places but changes rarely: theme, language, the logged-in user.
Signs you need Redux
- Many components, far apart, read and change the same data (a cart, a document editor, a set of filters).
- The update logic is complex: several kinds of change to the same data, each with rules.
- You want to answer "what changed, and why?" by looking at a log of actions.
- A bigger team benefits from one predictable pattern for every feature.
Signs you don't
- The data is used by one component or one small branch: keep it in
useState. - It's mostly data from a server: use RTK Query (part of Redux Toolkit) or TanStack Query, which handle loading, caching and refetching for you.
- The app is small. Adding Redux early costs more than it saves.
Gotchas
Recall
Can you answer these?
0/4
Answer out loud (or in your head) before you tap. That's what makes it stick.
Saved on this device only. No login.
