"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useIntersectionObserver = useIntersectionObserver;
var _compose = require("@wordpress/compose");
var _element = require("@wordpress/element");
var _ = require("../");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function useIntersectionObserver() {
  const observer = (0, _element.useContext)(_.IntersectionObserver);
  return (0, _compose.useRefEffect)(node => {
    if (observer) {
      observer.observe(node);
      return () => {
        observer.unobserve(node);
      };
    }
  }, [observer]);
}
//# sourceMappingURL=use-intersection-observer.js.map