UNPKG

@mondora/microfrontends

Version:

Library for embedding frontends into one another

41 lines 1.62 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importDefault(require("react")); const ChildApp_1 = __importDefault(require("./ChildApp")); class ChildAppReactComponent extends react_1.default.Component { constructor() { super(...arguments); this.state = { isLaunching: true }; this.childIFrame = react_1.default.createRef(); } async componentDidMount() { new ChildApp_1.default({ iframe: this.childIFrame.current, onLaunched: () => { this.setState({ isLaunching: false }); if (this.props.onLaunched) { this.props.onLaunched(); } }, suppliedMethods: this.props.suppliedMethods, launchData: this.props.launchData }).launch(); } render() { const { className, launchingPlaceholder, url } = this.props; const { isLaunching } = this.state; return (react_1.default.createElement(react_1.default.Fragment, null, isLaunching ? launchingPlaceholder : null, react_1.default.createElement("iframe", { src: url, className: className, ref: this.childIFrame, style: { display: isLaunching ? "none" : "initial" } }))); } } exports.default = ChildAppReactComponent; ChildAppReactComponent.defaultProps = { launchingPlaceholder: null }; //# sourceMappingURL=ChildAppReactComponent.js.map