Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 177x 177x 354x 354x 354x 177x | import { Ref, useRef } from "react"; export function useRefAndForward<T>(initialValue: T, forwardedRef: Ref<T>) { const ref = useRef(initialValue); const forward = (instance: T) => { ref.current = instance; Iif (typeof forwardedRef === "function") { forwardedRef(instance); } else Iif (forwardedRef) { (forwardedRef as any).current = instance; // eslint-disable-line no-param-reassign } }; return [ref, forward] as [typeof ref, typeof forward]; } |