Events and forms

Derive state instead of copying it

Compute validity, counts, and filtered views from source state instead of synchronizing duplicate fields.

9 minute lesson

~~~

The remaining-character count comes from the title, and the visible issue list comes from issues plus filters. That contrast gives us something useful to test instead of a rule to memorize.

Duplicated state drifts; a getter or expression can derive values from the authoritative inputs. The useful target is not encyclopedic coverage. Make one deliberate choice, observe its consequences, and know which requirement would make you revise it.

The happy path can hide a bad design: you can update the source and several cached copies in separate event handlers and still get one successful demo. Push past the demo. keep one source of truth and derive secondary values at the point of use or in a named getter, then test the condition most likely to prove the choice wrong.

The module is moving toward one outcome: Build a keyboard-usable issue editor whose state, validation, and submission lifecycle remain explicit. Save the before-and-after evidence now; it will make the final project review much more honest.

Introduce a duplicated count, demonstrate how it drifts, then replace it with derived state. Save the evidence, then explain which requirement would force you to choose a different design.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →