import { useCallback, useRef } from 'react';
export default function useForwardRef(ref, refObject) {
  const localRef = useRef(refObject?.current || null);
  const setRef = useCallback(r => {
    if (typeof ref === 'function') {
      ref(r);
    } else if (!!ref && ref.hasOwnProperty('current')) {
      ref.current = r;
    }
    localRef.current = r;
  }, [ref, localRef]);
  return [setRef, localRef];
}