"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = useForwardRef;
var _react = require("react");
function useForwardRef(ref, refObject) {
  const localRef = (0, _react.useRef)(refObject?.current || null);
  const setRef = (0, _react.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];
}