Execution — fw-02-mini-react-core
Steps extracted from CONCEPTS.md. Read the concepts first; this file is the doing.
Record results in observation.md; tick checkpoints in verification.md.
3. Build order
- Element model.
createElement(type, props, ...children)returning plain objects. No classes, no magic. Writeh('div', {id:'x'}, 'hi')by hand and look at the object. - DOM renderer. Render an element tree to real DOM. No diffing yet — mount only.
- Reconciliation. Given old and new trees, compute and apply the minimal DOM changes. Same-type nodes update in place; different types replace.
- Keyed children. Implement unkeyed first, find the bug (state attaching to the wrong item on reorder), then add keys. Do not skip the broken version — keys are meaningless until you have seen what they fix.
- Function components. Components return element trees; render recursively.
- State.
useStatewith a per-component slot list. Discover that this requires stable call order, and write down why the rules of hooks exist before reading that they do. - Effects.
useEffectwith dependency comparison, cleanup on unmount and on dep change. Get the cleanup ordering wrong at least once.
4. Failure Lab
- Unkeyed reorder. A list of inputs with text typed in them, reordered. Watch state follow position instead of identity. This is the canonical demonstration.
- Wrong key. Use array index as key on a reorderable list. Show the same bug returns.
- Hook order violation. Call a hook conditionally. Explain the failure precisely in terms of your slot list — you will explain it better than the docs do.
- Missing dependency. A stale closure reading old state. Then over-specify dependencies and produce an infinite effect loop. Both are real; describe the tension.
- Missing cleanup. Subscribe in an effect without unsubscribing; leak across remounts. Find
it in a heap snapshot (
bi-04's retainer-chain skill).