import { useEffect } from 'react';
export const useClickOutside = (refObject, callback) => {
  const handleClickOutside = e => {
    var _refObject$current;
    if (!(refObject !== null && refObject !== void 0 && (_refObject$current = refObject.current) !== null && _refObject$current !== void 0 && _refObject$current.contains(e.target))) {
      callback();
    }
  };
  useEffect(() => {
    document.addEventListener('mousedown', handleClickOutside);
    return () => document.removeEventListener('mousedown', handleClickOutside);
  });
};