"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _react = _interopRequireWildcard(require("react"));

var _useInViewport3 = _interopRequireDefault(require("../use-in-viewport"));

var LazyDetector = function LazyDetector(props) {
  var ref = (0, _react.useRef)(null);

  var _useInViewport = (0, _useInViewport3.default)(ref),
      _useInViewport2 = (0, _slicedToArray2.default)(_useInViewport, 1),
      inViewport = _useInViewport2[0];

  (0, _react.useEffect)(function () {
    if (inViewport) {
      props.onActive();
    }
  }, [inViewport]);
  return /*#__PURE__*/_react.default.createElement("div", {
    ref: ref
  });
};

var _default = LazyDetector;
exports.default = _default;