Learning object 50 of 100
Dynamic list rendering laboratory
Dispatch actions to a list app, watch a reducer produce each new state and the list re-render, and replay the action log.
Loading…
What it shows
In state-driven rendering, every change is an action handled by a pure reducer: (state, action) => new state. A store keeps the state, runs the reducer on dispatch and notifies subscribers, which re-render their part of the page. Because every change is an action, the log can replay or undo the history.
Guided experiment
- Add and toggle a few items in the preview and read the action log in the console.
- Press Undo. Which actions are replayed?
- Change the reducer so toggle cannot un-complete an item.
Predict
A reducer receives an unknown action type. What should it return?
Related
Lessons: Lesson 73: State-driven rendering
Projects: Project 9: Shopping Cart Price Calculator
Source: web/assets/js/objects/object-050.js in the companion repository.