Files
Speedtest-Tracker/conf/site/node_modules/react-overlays/esm/Portal.js
Henry Whitaker ea5808047f Tweaked gitignore
gitignore removed all composer and npm files, so automated builds would fail
2020-04-12 21:24:03 +01:00

33 lines
1.0 KiB
JavaScript
Vendored

import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import useWaitForDOMRef from './utils/useWaitForDOMRef';
var propTypes = {
/**
* A DOM element, Ref to an element, or function that returns either. The `container` will have the Portal children
* appended to it.
*/
container: PropTypes.any,
onRendered: PropTypes.func
};
/**
* The `<Portal/>` component renders its children into a new "subtree" outside of current component hierarchy.
* You can think of it as a declarative `appendChild()`, or jQuery's `$.fn.appendTo()`.
* The children of `<Portal/>` component will be appended to the `container` specified.
*
*/
var Portal = function Portal(_ref) {
var container = _ref.container,
children = _ref.children,
onRendered = _ref.onRendered;
var resolvedContainer = useWaitForDOMRef(container, onRendered);
return resolvedContainer ? ReactDOM.createPortal(children, resolvedContainer) : null;
};
Portal.displayName = 'Portal';
Portal.propTypes = propTypes;
/**
* @component
*/
export default Portal;