Separate data transitions from DOM updates.
- state
- actions
- render
- derived data
Represent application state explicitly. Event handlers translate user actions into state changes, then render the affected UI. Derived values such as counts should be calculated from state rather than stored redundantly. A predictable flow reduces bugs where display and data disagree.
Changing a DOM label without updating state causes the next render to undo the change.
Build a small filterable task board with one state object and a render function.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- Explain the core idea in your own words without reading the code.
- Change one input and predict the output before running it.
- Test one boundary or failure case, then record what you changed.