import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import React, { useEffect, useRef } from 'react';
import useInViewport from '../use-in-viewport';

var LazyDetector = function LazyDetector(props) {
  var ref = useRef(null);

  var _useInViewport = useInViewport(ref),
      _useInViewport2 = _slicedToArray(_useInViewport, 1),
      inViewport = _useInViewport2[0];

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

export default LazyDetector;