"use strict";

exports.__esModule = true;
exports.default = useSsrCompat;

var _react = require("react");

function useSsrCompat() {
  var _useState = (0, _react.useState)(false),
      mounted = _useState[0],
      setMounted = _useState[1];

  var _useState2 = (0, _react.useState)(mounted),
      rendered = _useState2[0],
      setRendered = _useState2[1];

  (0, _react.useEffect)(function () {
    setMounted(true);
  }, []);
  (0, _react.useEffect)(function () {
    if (mounted) {
      setRendered(true);
    }
  }, [mounted]);
  return [(0, _react.useCallback)(function (render) {
    return mounted ? render() : null;
  }, [mounted]), rendered];
}