fix(11-03): avoid setState/ref access during render in EditableCell

- remove value-sync useEffect + render-time ref read that violated
  react-hooks/set-state-in-effect and react-hooks/refs lint rules
- toggle display now reads value directly instead of tempValue,
  which is only meaningful while isEditing is true
This commit is contained in:
2026-06-13 15:51:41 +02:00
parent 3514a3710d
commit 55276c19fe
+1 -5
View File
@@ -29,10 +29,6 @@ export function EditableCell({
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null); const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
useEffect(() => {
setTempValue(String(value));
}, [value]);
useEffect(() => { useEffect(() => {
if (isEditing && inputRef.current) { if (isEditing && inputRef.current) {
inputRef.current.focus(); inputRef.current.focus();
@@ -78,7 +74,7 @@ export function EditableCell({
if (!isEditing) { if (!isEditing) {
let display: string; let display: string;
if (type === "toggle") { if (type === "toggle") {
display = tempValue === "true" ? "✓ Attivo" : "✗ Disattivato"; display = String(value) === "true" ? "✓ Attivo" : "✗ Disattivato";
} else { } else {
const raw = String(value); const raw = String(value);
display = formatDisplay ? formatDisplay(raw) : raw || "—"; display = formatDisplay ? formatDisplay(raw) : raw || "—";