UNPKG

@shopify/app-bridge-host

Version:

App Bridge Host contains middleware and components that are meant to be consumed by the app's host. The middleware and `Frame` component are responsible for facilitating messages posted between the client and host, and used to act on actions sent from the

25 lines (24 loc) 1.11 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var react_1 = __importDefault(require("react")); var react_redux_1 = require("react-redux"); var async_1 = require("./store/async"); var redux_1 = require("redux"); /** * 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-" + index; return Component ? react_1.default.createElement(Component, { key: key, globalStore: store }) : null; }); return react_1.default.createElement("div", { style: style }, dynamicContent); } exports.Host = Host; exports.default = redux_1.compose(react_redux_1.connect(function (state) { return ({ store: state[async_1.APP_BRIDGE_KEY] }); }))(Host);