react-juejin icon indicating copy to clipboard operation
react-juejin copied to clipboard

打包优化

Open jifengdehao opened this issue 5 years ago • 1 comments

@可以添加lazy懒加载哈哈哈 main.js

/// React 16.6 or higher
// 使用Suspense做Code-Splitting
const withSuspense = (Component) => {
    return (props) => (
        <Suspense fallback={null}>
            <Component {...props} />
        </Suspense>
    )
}
const Home = withSuspense(lazy(() => import("../home/index")))
const Post = withSuspense(lazy(() => import("../post/index")))
const Dynamic = withSuspense(lazy(() => import("../dynamic/index")))
const Topic = withSuspense(lazy(() => import("../topic/index")))
const Brochure = withSuspense(lazy(() => import("../brochure/index")))
const Activity = withSuspense(lazy(() => import("../activity/index")))

jifengdehao avatar Mar 24 '19 14:03 jifengdehao

@可以添加lazy懒加载哈哈哈 main.js

/// React 16.6 or higher
// 使用Suspense做Code-Splitting
const withSuspense = (Component) => {
    return (props) => (
        <Suspense fallback={null}>
            <Component {...props} />
        </Suspense>
    )
}
const Home = withSuspense(lazy(() => import("../home/index")))
const Post = withSuspense(lazy(() => import("../post/index")))
const Dynamic = withSuspense(lazy(() => import("../dynamic/index")))
const Topic = withSuspense(lazy(() => import("../topic/index")))
const Brochure = withSuspense(lazy(() => import("../brochure/index")))
const Activity = withSuspense(lazy(() => import("../activity/index")))

多谢哈

rocky-191 avatar Mar 25 '19 01:03 rocky-191