Simplify editable cell signature

Signed-off-by: Jonathan <contact@grafikart.fr>
This commit is contained in:
Jonathan
2025-11-14 19:22:46 +01:00
committed by Émile Ré
parent cb5daab175
commit 789775f2fe
21 changed files with 762 additions and 451 deletions

View File

@@ -0,0 +1,18 @@
import { useCallback, useRef, useState } from "react";
/**
* A useState hook that also returns a ref to the current state (usable in callbacks)
*/
export function useStateWithRef<T>(initialValue: T) {
const [state, setState] = useState(initialValue);
const ref = useRef(state);
return [
state,
useCallback((v: T) => {
setState(v);
ref.current = v;
}, []),
ref,
] as const;
}