@wugui/plugin-lazy
v1.0.1-alpha.0
Published
Suspense and lazy
Downloads
2
Readme
🧲 LazyPlugin
基于 React.Suspense 与 React.Lazy,提供异步组件支持。
⚠️
// React.lazy 有 bug
// https://github.com/facebook/react/issues/14188
🧭 使用 usage
安装 install
yarn add @wugui/plugin-lazy
示例 examples
import { Framework } from "@wugui/core";
import LazyPlugin from "@wugui/plugin-lazy";
const options = process.env.NODE_ENV === "production"
? require("./config/config.prod")
: require("./config/config.dev");
export default class MyFramework extends Framework {
public static Plugins = [
// 作为 Framework 的静态属性
LazyPlugin,
];
public static options: any = options.default;
}
or
import SimpleFramework from "@wugui/framework-simple";
import LazyPlugin from "@wugui/plugin-lazy";
const options = process.env.NODE_ENV === "production"
? require("./config/config.prod")
: require("./config/config.dev");
new SimpleFramework({
Plugins: [
// 作为 Framework 的实例属性
LazyPlugin,
],
...options.default,
modules: [
import("./modules/home"),
// 404
{
path: "*",
lazy: () => import("./components/NotFound"),
},
],
}).mount();