githubnext/chopinPublic

Let's compose rich plans together

Replace reset-on-prop Effect with render-time state adjustment in PlanChanges Chip

The Chip component in packages/editor/src/changes-chip.tsx used a
useEffect keyed on [waiting] whose only job was to call setOpen(false)
once the waiting count reached zero. That is a reset-or-adjust-state
Effect responding purely to a prop change, which forces an extra
render/commit pass after the state that should have driven it already
changed (React fires the Effect only after the DOM committed with the
stale 'open' value).

Replaced it with the documented 'adjusting state during render'
pattern: track the waiting value the open state was computed for, and
when it changes, call setOpen(false) synchronously in the render body
before returning JSX. React bails out of re-rendering the children in
this case, avoiding the flash of a stale open list and the extra
commit the Effect approach caused.

Verification: bun/dprint/oxlint were unavailable in this sandboxed
environment (no network access to install bun), so this was verified
by manual review against React's documented state-adjustment pattern
and by confirming the surrounding formatting/style matches the file's
existing conventions.
GAgithub-actions[bot] authored committed by GitHub
c31fa2aPatch
Parentb33895b
1 file changed+10-4
StackedSplit
packages/editor/src/changes-chip.tsx+10 −4