mirror of
https://github.com/reconurge/flowsint.git
synced 2026-11-08 14:35:41 -06:00
The react-hooks/set-state-in-effect cleanup earlier in this branch
converted several "sync local form state from loaded data" effects to
the adjust-during-render pattern: track a prevValue via useState, and
when it differs from the current value, sync state during render
instead of in an effect.
That pattern has a real gap the original effects didn't: useEffect
runs on mount regardless of dependencies, but `useState(value)` for
the tracked prevValue captures the *current* value immediately, so on
mount `value === prevValue` already and the sync block never fires.
Any of these components that can mount with data already available
(query cache hit, or a prop that's simply non-null from the start)
silently kept its hardcoded-empty initial state forever — until the
underlying value later *changed* to something else.
Confirmed regression: node details panel's form (name/color/icon/...)
stayed empty on the first node selected after mount, only populating
once you clicked a second, different node. Same shape, same fix
(derive the initial useState from the current value via a lazy
initializer instead of a hardcoded default) applied to every sibling
with the same bug shape: sketch settings form, analysis title, user
profile form, and the custom-type editor (which also never called its
add-first-field fallback for a brand new type, for the same reason).
Audited every other adjust-during-render conversion from that branch;
the rest already seeded their initial state directly from the current
prop/value (e.g. useState(value) instead of useState('')), so they
don't have this gap.