Files
sim/.claude
Waleed 2c5ee4a8db chore(rules): canonical useState prev-tracker for render-phase adjust + no-render-in-render caveat (#5333)
Two recurring pitfalls surfaced by the /w react-doctor pass, verified against
react.dev:
- sim-hooks.md: adjusting state on a prop transition uses the React-canonical
  useState prev-value tracker (NOT a useRef — React forbids reading/writing
  ref.current during render; the react-hooks 'refs' lint flags it, and useState
  is concurrent-safe). The tracker's initial value decides mount behavior
  (sentinel vs current value) — a mis-seed silently drops the mount action. The
  existing useRef variant is noted as discouraged for new code.
- sim-components.md: no-render-in-render is a false positive for a helper called
  inline (reconciled by position, no remount); extract only when mechanical.

Refs: react.dev useState 'Storing information from previous renders'; useRef
'Do not write or read ref.current during rendering'; react-hooks 'refs' lint.
2026-07-01 13:50:32 -07:00
..