diff --git a/frontend/src/components/SettingsModal.tsx b/frontend/src/components/SettingsModal.tsx index 62b14e7..af7c7b8 100644 --- a/frontend/src/components/SettingsModal.tsx +++ b/frontend/src/components/SettingsModal.tsx @@ -3394,9 +3394,16 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan // register — the output on/off. The voltage and current SET points are shown // because they are worth seeing, and are not editable here: they belong to the // supply's front panel, and a logbook that can set them can set them wrong. + // NO HOOKS IN HERE. This panel is called as a plain function, like its + // neighbours — PANELS[x]() — so a useState of its own lands in SettingsModal's + // hook list and only while this section is open. React counts those, and it + // stopped drawing the moment the section was clicked (error #310, "rendered + // more hooks than during the previous render"). The COM ports come from the + // list SettingsModal already loads for the Winkeyer panel: one machine, one + // set of serial ports, loaded once. function PSUPanelSettings() { - const [ports, setPorts] = useState([]); - useEffect(() => { ListSerialPorts().then((p) => setPorts((p ?? []) as string[])).catch(() => setPorts([])); }, []); + const ports = wkPorts; + const setPorts = setWkPorts; return ( <>