0
Challenge · 62Architecture & State
Redux Toolkit
Ecoused in ~70% of apps
You learned useReducer (#31) for one component. Redux is that same idea — a pure (state, action) reducer — but the store lives OUTSIDE the tree, so any component can read it or dispatch to it without prop-drilling. Redux Toolkit (RTK) is the only way you should write Redux in 2026: it kills the old boilerplate and is what every large or legacy codebase you'll join actually uses.
Core idea. Redux Toolkit gives you one global store built from createSlice reducers (which use Immer so you write 'mutating' code that's actually immutable); components read it with useSelector and change it by dispatching actions with useDispatch — a single, predictable, debuggable one-way data flow.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
1 · a component dispatches an action object
action
dispatch one →
store · reducer (Immer)
counter: (s) => { s.value += … }
user: (s) => { s.points += … }
Immer drafts the “mutation” → returns a new object
new state (out)
counter: { value: 0 }
user: { points: 50 }
3 · useSelector components read their slice — only the one whose slice changed re-renders
<CountBadge/>re-rendered 1×
useSelector(s => s.counter.value)
reads0
<PointsBadge/>re-rendered 1×
useSelector(s => s.user.points)
reads50
One-way loop: dispatch → store runs the slice reducer → a new state object → selectors read it. The reducer looks like it mutates, but Immer makes the update immutable — and the untouched slice keeps its old reference, so its useSelector never re-renders.
↑ play a little first, then dig in