/** * @file Hook for keeping a ref in sync with the latest value. */ import * as React from "react"; /** * Returns a ref object that always points to the latest provided value. * Useful for stable callbacks that need the newest implementation/state without re-subscribing. */ export function useLatestRef(value: T): React.MutableRefObject { const ref = React.useRef(value); ref.current = value; return ref; }