@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
25 lines (22 loc) • 947 B
JavaScript
import React from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { APP_BRIDGE_KEY } from './store/index.js';
/**
* 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.createElement(Component, { key: key, globalStore: store }) : null;
});
if (!style) {
return React.createElement(React.Fragment, null, dynamicContent);
}
return React.createElement("div", { style: style }, dynamicContent);
}
var Host$1 = compose(connect(function (state) { return ({ store: state[APP_BRIDGE_KEY] }); }))(Host);
export { Host, Host$1 as default };