import { useRef } from 'react'; const UNRESOLVED = Symbol(); export function useStable(getValue: () => T): T { const ref = useRef(UNRESOLVED); if (ref.current === UNRESOLVED) { ref.current = getValue(); } return ref.current; }