import { useRef } from '../lib/teact/teact'; import type { Signal } from '../util/signals'; import useEffectOnce from './useEffectOnce'; // Allows to use signal value as "silent" dependency in hooks (not causing updates) export function useSignalRef(getValue: Signal) { const ref = useRef(getValue()); useEffectOnce(() => { return getValue.subscribe(() => { ref.current = getValue(); }); }); return ref; }