@shopify/polaris
Version:
Shopify’s product component library
22 lines (19 loc) • 817 B
JavaScript
import React$1, { useState, useMemo } from 'react';
import { PortalsManagerContext } from '../../utilities/portals/context.js';
import { PortalsContainer as PortalsContainer$1 } from './components/PortalsContainer/PortalsContainer.js';
function PortalsManager({
children,
container
}) {
const [portalContainerElement, setPortalContainerElement] = useState(null);
const currentContainer = container != null ? container : portalContainerElement;
const contextValue = useMemo(() => ({
container: currentContainer
}), [currentContainer]);
return /*#__PURE__*/React$1.createElement(PortalsManagerContext.Provider, {
value: contextValue
}, children, container ? null : /*#__PURE__*/React$1.createElement(PortalsContainer$1, {
ref: setPortalContainerElement
}));
}
export { PortalsManager };