UNPKG

dm-web-react

Version:

The DM web client with React.

64 lines 2.66 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import * as React from "react"; import * as Loadable from "react-loadable"; import i18n from "./common/i18n"; import Loading from "./components/Loading"; export default (function () { var LoadableComponent = Loadable.Map({ loader: { Component: function () { return import(/* webpackChunkName: "app" */ "./containers/App"); }, i18n: function () { return fetch("./i18n/app/" + i18n.language.toLowerCase() + ".json").then(function (res) { return res.json(); }); }, }, loading: function (props) { if (props.error) { return (React.createElement("div", null, "Error! ", React.createElement("button", { onClick: props.retry }, "Retry"))); } else { return props.pastDelay ? React.createElement(Loading, null) : null; } }, render: function (loaded, props) { // add i18n resources var i18nResources = loaded.i18n; var Component = loaded.Component.default; return React.createElement(Component, __assign({}, props, { i18nResources: i18nResources })); }, }); var Component = /** @class */ (function (_super) { __extends(Component, _super); function Component(props) { return _super.call(this, props) || this; } Component.prototype.render = function () { return React.createElement(LoadableComponent, null); }; return Component; }(React.Component)); return Component; }); //# sourceMappingURL=AppLoader.js.map