'use strict';

var React = require('react');

/*
 * Inspired by:
 *
 * - https://react.dev/learn/separating-events-from-effects#declaring-an-effect-event
 * - https://legacy.reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
 */
function useEffectEvent(callback) {
  const ref = React.useRef(() => {
    throw new Error('Cannot call an event handler while rendering.');
  });
  React.useEffect(() => {
    ref.current = callback;
  });
  return React.useCallback((...args) => ref.current(...args), []);
}

exports.useEffectEvent = useEffectEvent;
//# sourceMappingURL=useEffectEvent.js.map
