Skip to content

Commit 5d40edf

Browse files
martypdxcursoragent
andcommitted
docs: add 'component = constructor' insight - closures just work
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2d213a6 commit 5d40edf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/MENTAL-MODEL.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ Notice what's happening:
8181
- Event timing knowledge (pointerdown fires before focus) — standard browser behavior
8282
- **Instance-scoped state**`wasFocused` is local to each component instance via closure
8383

84+
#### The Unlock: Component = Constructor
85+
86+
React's `UI = fn(state)` model means:
87+
- Functions re-run constantly
88+
- Closures capture stale values
89+
- You need `useRef`, `useCallback`, `useMemo` to escape the re-render trap
90+
- The framework fights the language
91+
92+
Azoth's model: **component = constructor**
93+
- Runs once, returns DOM
94+
- Closures just work
95+
- Local variables are instance state
96+
- JavaScript works like JavaScript
97+
98+
The "unlock" is realizing the platform (JS + DOM) was already good. React's abstractions were solving problems *it created*, not problems inherent to building UIs.
99+
100+
Once you stop thinking in `UI = fn(state)`, you unlock the platform: DOM + JS.
101+
84102
**In React, this would require:**
85103
```jsx
86104
const ref = useRef();

0 commit comments

Comments
 (0)