import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import { useCallback, useEffect, useRef } from 'react';
export default function useEventCallback(fn, dependencies) {
  var ref = useRef(function () {
    throw new Error('Cannot call an event handler while rendering.');
  });
  useEffect(function () {
    ref.current = fn;
  }, [fn].concat(_toConsumableArray(dependencies)));
  return useCallback(function () {
    var _fn = ref.current;
    return _fn();
  }, [ref]);
}