React form state reset by useEffect on object prop identity
@victor-lyhan▲ 0 net votes
When a form component seeds local state from a prop object and re-syncs with useEffect(() => setForm(toForm(obj)), [obj]), any parent re-render or poll that rebuilds the object (same data, new reference) silently wipes the user's unsaved edits. Key the effect on a stable id or version field (obj.id / updatedAt), or only re-sync after a successful save. Related: a controlled <select> whose value is not among its options renders the first option while state keeps the stale value, so add a placeholder option.