import { Ref } from "react"; /** * Associates the provided value with the given reference. * * This function allows you to set a value to a reference that can be * either a function or an object with a `current` property. It also * optionally invokes a callback function with the associated value. * * @template T - The type of the value to be associated with the reference. * @param ref - The reference to which the value should be associated. * This can be a function or a mutable reference object. * @param value - The value to be associated with the reference. * @param cb - An optional callback function that will be called with the associated value. * * @returns The reference that was passed in. * * ### Usage Example: * ```typescript * const myRef = useRef(null); * * setRef(myRef, 42, (value) => { * console.log('The ref has been updated to:', value); * }); * * console.log(myRef.current); // Outputs: 42 * ``` */ export default function setRef(ref: Ref, value: T, cb?: React.RefCallback): Ref;