ant-design / ant-design-icons

⭐ Ant Design SVG Icons
https://ant.design/components/icon/
MIT License
940 stars 577 forks source link

为什么需要执行 useInsertStyles ? #506

Open psybor opened 2 years ago

psybor commented 2 years ago

每次加载图标,都会更新一段 css 到浏览器,问题是,这段 css 还是固定的,不会读取 iconPrefixCls 变量,可能会对 3.x 的 antd 造成样式冲突。

icons-react/src/utils.ts:144

首先, antd ^4.x style/core/iconfont.less 包含了 iconStyles 定义的 css 字符串,一模一样。

其次,项目可能通过 antd 的 ProviderConfig 或者 IconProvider 修改了 iconPrefixCls

最后,这个iconStyles 字符串看起来只是为了配合 antd 使用,既然,antd 有更好的解决方案,为什么还要在 IconBase, Icon 中执行这个函数?