import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { useState, useEffect } from 'react';

var useHasTextOverflow = function useHasTextOverflow(elementRef) {
  var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isOverflowed = _useState2[0],
    setIsOverflowed = _useState2[1];
  useEffect(function () {
    var checkOverflow = function checkOverflow() {
      if (elementRef.current) {
        setIsOverflowed(elementRef.current.scrollHeight > elementRef.current.clientHeight || elementRef.current.scrollWidth > elementRef.current.clientWidth);
      }
    };
    checkOverflow();

    // Optionally add a resize listener
    var handleResize = function handleResize() {
      return checkOverflow();
    };
    window.addEventListener('resize', handleResize);
    return function () {
      window.removeEventListener('resize', handleResize);
    };
  }, [elementRef, text]);
  return isOverflowed;
};
var useHasTextOverflow$1 = useHasTextOverflow;

export { useHasTextOverflow$1 as default };
