UNPKG

@shopgate/pwa-common

Version:

Common library for the Shopgate Connect PWA.

12 lines 1.29 kB
import React,{Fragment}from'react';import PropTypes from'prop-types';import Portal from"../Portal";import{AFTER,BEFORE}from"../../constants/Portals";/** * The SurroundPortals component renders three Portal component. The main portal is wrapped around * its children, the two additional portals are rendered before and after the main portal. * The names of the additional portals are automatically created from the name of the main portal * with a ".before" and ".after" suffix. * * @param {Object} props The component props * @param {string} props.portalName Name for the main portal * @param {Object} props.portalProps Props that are assigned to the portals * @param {React.ReactNode} props.children Component children * @returns {JSX.Element} */var SurroundPortals=function SurroundPortals(_ref){var portalName=_ref.portalName,portalProps=_ref.portalProps,children=_ref.children;return React.createElement(Fragment,null,React.createElement(Portal,{name:"".concat(portalName,".").concat(BEFORE),props:portalProps}),React.createElement(Portal,{name:portalName,props:portalProps},children),React.createElement(Portal,{name:"".concat(portalName,".").concat(AFTER),props:portalProps}));};SurroundPortals.defaultProps={children:null,portalProps:null};export default SurroundPortals;