39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
Object.defineProperty(exports, "default", {
|
|
enumerable: true,
|
|
get: function() {
|
|
return _default;
|
|
}
|
|
});
|
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
const _react = /*#__PURE__*/ _interop_require_default._(require("react"));
|
|
const _dynamicnossr = require("./dynamic-no-ssr");
|
|
function Loadable(options) {
|
|
const opts = Object.assign({
|
|
loader: null,
|
|
loading: null,
|
|
ssr: true
|
|
}, options);
|
|
opts.lazy = /*#__PURE__*/ _react.default.lazy(opts.loader);
|
|
function LoadableComponent(props) {
|
|
const Loading = opts.loading;
|
|
const fallbackElement = /*#__PURE__*/ _react.default.createElement(Loading, {
|
|
isLoading: true,
|
|
pastDelay: true,
|
|
error: null
|
|
});
|
|
const Wrap = opts.ssr ? _react.default.Fragment : _dynamicnossr.NoSSR;
|
|
const Lazy = opts.lazy;
|
|
return /*#__PURE__*/ _react.default.createElement(_react.default.Suspense, {
|
|
fallback: fallbackElement
|
|
}, /*#__PURE__*/ _react.default.createElement(Wrap, null, /*#__PURE__*/ _react.default.createElement(Lazy, props)));
|
|
}
|
|
LoadableComponent.displayName = "LoadableComponent";
|
|
return LoadableComponent;
|
|
}
|
|
const _default = Loadable;
|
|
|
|
//# sourceMappingURL=loadable.js.map
|