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:
@@ -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 || "—";
|
||||||
|
|||||||
Reference in New Issue
Block a user