react-juejin
react-juejin copied to clipboard
打包优化
@可以添加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")))
@可以添加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")))
多谢哈