UNPKG

@shopify/app-bridge-host

Version:

App Bridge Host contains components and middleware to be consumed by the app's host, as well as the host itself. The middleware and `Frame` component are responsible for facilitating communication between the client and host, and used to act on actions se

34 lines (27 loc) 1.27 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var React = require('react'); var reactRedux = require('react-redux'); var redux = require('redux'); var store_index = require('./store/index.js'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var React__default = /*#__PURE__*/_interopDefault(React); /** * A component that renders an array of components * and provides the global App Bridge store as a prop * @public * */ function Host(props) { var components = props.components, store = props.store, style = props.style; var dynamicContent = components.map(function (Component, index) { var key = Component.displayName || "Host-Component-".concat(index); return Component ? React__default.default.createElement(Component, { key: key, globalStore: store }) : null; }); if (!style) { return React__default.default.createElement(React__default.default.Fragment, null, dynamicContent); } return React__default.default.createElement("div", { style: style }, dynamicContent); } var Host$1 = redux.compose(reactRedux.connect(function (state) { return ({ store: state[store_index.APP_BRIDGE_KEY] }); }))(Host); exports.Host = Host; exports.default = Host$1;