reach_portal_esm_Portal = function Portal(_ref) {
  var children = _ref.children,
      _ref$type = _ref.type,
      type = _ref$type === void 0 ? "reach-portal" : _ref$type;
  var mountNode = Object(react["useRef"])(null);
  var portalNode = Object(react["useRef"])(null);
  var forceUpdate = useForceUpdate();
  useIsomorphicLayoutEffect(function () {
    // This ref may be null when a hot-loader replaces components on the page
    if (!mountNode.current) return; // It's possible that the content of the portal has, itself, been portaled.
    // In that case, it's important to append to the correct document element.

    var ownerDocument = mountNode.current.ownerDocument;
    portalNode.current = ownerDocument == null ? void 0 : ownerDocument.createElement(type);
    ownerDocument.body.appendChild(portalNode.current);
    forceUpdate();
    return function () {
      if (portalNode.current && portalNode.current.ownerDocument) {
        portalNode.current.ownerDocument.body.removeChild(portalNode.current);
      }
    };
  }, [type, forceUpdate]);
  return portalNode.current ? /*#__PURE__*/Object(react_dom["createPortal"])(children, portalNode.current) : /*#__PURE__*/Object(react["createElement"])("span", {
    ref: mountNode
  });
}
Portal

@see Docs https://reach.tech/portal#portal