"use strict";

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

exports.__esModule = true;
exports.ScrollToOnRender = void 0;

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

var _lib = require("@sentecacommerce-theme/lib");

var ScrollToOnRender = function ScrollToOnRender() {
  var containerRef = (0, _react.useRef)(null);

  var _useScrollTo = (0, _lib.useScrollTo)(containerRef.current || undefined, 2),
      scrollTo = _useScrollTo.scrollTo;

  (0, _react.useEffect)(function () {
    setTimeout(function () {
      if (!containerRef.current) return;
      scrollTo((0, _lib.getElementOffset)(containerRef.current).top);
    }, 50);
  }, []);
  return /*#__PURE__*/_react["default"].createElement("div", {
    ref: containerRef
  });
};

exports.ScrollToOnRender = ScrollToOnRender;
//# sourceMappingURL=index.js.map