Skip to content

Latest commit

 

History

History
36 lines (23 loc) · 1.01 KB

File metadata and controls

36 lines (23 loc) · 1.01 KB

46. State and rendering architecture

Separate data transitions from DOM updates.

Learn

  • state
  • actions
  • render
  • derived data

How it works

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.

Common mistake

Changing a DOM label without updating state causes the next render to undo the change.

Guided challenge

Build a small filterable task board with one state object and a render function.

Run the example

Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.

Completion check

  • 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.