UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

55 lines (43 loc) 1.56 kB
import _extends from "@babel/runtime/helpers/extends"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _createSuper from "@babel/runtime/helpers/createSuper"; import React, { Component } from 'react'; import Spin from '../spin'; import exception from './exception'; var asyncComponent = function asyncComponent(importComponent) { var AsyncComponent = /*#__PURE__*/function (_Component) { _inherits(AsyncComponent, _Component); var _super = _createSuper(AsyncComponent); function AsyncComponent() { var _this; _classCallCheck(this, AsyncComponent); _this = _super.apply(this, arguments); _this.state = {}; return _this; } _createClass(AsyncComponent, [{ key: "componentDidMount", value: function componentDidMount() { var _this2 = this; importComponent().then(function (_ref) { var component = _ref["default"]; _this2.setState({ component: component }); }, exception); } }, { key: "render", value: function render() { var Cmp = this.state.component; return Cmp ? /*#__PURE__*/React.createElement(Cmp, _extends({}, this.props)) : /*#__PURE__*/React.createElement(Spin, null); } }]); return AsyncComponent; }(Component); return AsyncComponent; }; export default asyncComponent; //# sourceMappingURL=AsyncComponent.js.map