import type { RefObject, Ref } from 'react' import { useRef, useEffect } from 'react' const useCombinedRefs = (...refs: (RefObject | Ref)[]) => { const targetRef = useRef(null) useEffect(() => { refs.forEach(ref => { if (!ref) { return } if (typeof ref === 'function') { ref(targetRef.current) } else { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore ref.current = targetRef.current } }) }, [refs]) return targetRef } export default useCombinedRefs