Open jinliming2 opened 5 years ago
Looking for the same. For some reason, React.lazy
does not seem to work with with antd
. I am using CRA and unable to make the antd components load lazily no matter how much I tried. Wish they were compatible.
Was able to make the antd
component load lazily as below:
const Card = React.lazy(() => import(/* webpackChunkName: "antSidebars", webpackPreload: true */ 'antd/lib/card/index'));
const Menu = React.lazy(() => import(/* webpackChunkName: "antSidebars", webpackPreload: true */ 'antd/lib/menu/index'));
const MenuItem = React.lazy(() => import(/* webpackChunkName: "antSidebars", webpackPreload: true */ 'antd/lib/menu/MenuItem'));
const SubMenu = React.lazy(() => import(/* webpackChunkName: "antSidebars", webpackPreload: true */ 'antd/lib/menu/SubMenu'));
什么原因呢 有其他解决办法吗
Can this plugin compatible with React.lazy and Loadable Components?
Or something like: