import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import React, { useState, useEffect } from "react";
import { Spin } from '@whalecloud/fdx';
import RenderPage from "./RenderPage";
import appRender from "../../models/appRender";

var FormRender = function FormRender(props) {
  var nameSpace = props.nameSpace;

  var _useState = useState(false),
      _useState2 = _slicedToArray(_useState, 2),
      load = _useState2[0],
      setLoad = _useState2[1];

  useEffect(function () {
    var models = window.g_app._models || [];
    var registFlag = false;

    if (nameSpace) {
      var exit = models.findIndex(function (v) {
        return v.namespace === nameSpace;
      }) > -1;
      registFlag = !exit;
    } else if (!models.some(function (v) {
      return v.namespace === 'appRender';
    })) {
      registFlag = true;
    }

    if (registFlag) {
      // 注册
      window.g_app.model(appRender(nameSpace));
    }

    setLoad(true);
  }, []);
  return load ? /*#__PURE__*/React.createElement(RenderPage, props) : /*#__PURE__*/React.createElement(Spin, null);
};

export default FormRender;
//# sourceMappingURL=PageRender.js.map