当前位置:网站首页>import error: ‘Icon‘ is not exported from ‘antd‘. Import icon error
import error: ‘Icon‘ is not exported from ‘antd‘. Import icon error
2022-07-26 08:21:00 【Timeline principle】
Issues an error :
Attempted import error: 'Icon' is not exported from 'antd'.
Question why :
Ant Design from v3 Upgrade to v4 Lead to
Icon upgrade ( Click to view the document )
stay [email protected] in , We introduced svg Icon ( Why use svg Icon ?). Using a string named icon API Can't load on demand , Therefore, the total introduction of svg Icon file , This greatly increases the size of the packed product . stay 4.0 in , We adjusted the use of icons API To support tree shaking, Reduce antd The default package size is about 150 KB ( Gzipped ).
Old edition Icon The way of use will be abandoned :
import {
Icon, Button } from 'antd';
const Demo = () => (
<div>
<Icon type="smile" />
<Button icon="smile" />
</div>
);
4.0 On demand introduction will be adopted in :
import {
Button } from 'antd';
// tree-shaking supported
- import {
Icon } from 'antd';
+ import {
SmileOutlined } from '@ant-design/icons';
const Demo = () => (
<div>
- <Icon type="smile" />
+ <SmileOutlined />
<Button icon={
<SmileOutlined />} />
</div>
);
// or directly import
import SmileOutlined from '@ant-design/icons/SmileOutlined';
You will still be able to use it through compatible packages :
import {
Button } from 'antd';
import {
Icon } from '@ant-design/compatible';
const Demo = () => (
<div>
<Icon type="smile" />
<Button icon="smile" />
</div>
);
Solution :
We can solve it through the solution described in the document , However, the following errors will still be reported after the execution :
Module not found: Can't resolve '@ant-design/compatible'
We can solve it with the following order :
npm add @ant-design/compatible
边栏推荐
- BGP routing principle
- 第三天作业
- Bee guitar score high octave and low octave
- vscode国内的镜像服务器加速
- Vscode domestic image server acceleration
- Kotlin中room数据库的使用
- 22-07-14 personal training match 2 competition experience
- Differences and connections of previewkeydown, Keydown, keypress and Keyup in C WinForm
- 2022-07-14 group 5 Gu Xiangquan's learning notes day07
- Sed job
猜你喜欢

基础乐理 节奏联系题,很重要

全网最全:Mysql六种约束详解

A little awesome, 130000 a month+

Software engineering -- dental clinic -- demand acquisition

2022-07-14 group 5 Gu Xiangquan's learning notes day07

苹果强硬新规:用第三方支付也要抽成,开发者亏大了!

OSPF总结

BGP的基本配置

One click deployment lamp and LNMP architecture

Burp suite Chapter 6 how to use burp spider
随机推荐
Burp Suite-第四章 SSL和Proxy高级选项
Exam summary on July 15, 2022
sed作业
OSPF summary
mysql函数汇总之条件判断函数
Burp Suite-第五章 如何使用Burp Target
This is a picture
基础乐理 节奏联系题,很重要
Seq2seq and attention model learning notes
小组成员参加2022中国多媒体大会
R language foundation
Zroi easy sum (generating function, block, DP, combination, polynomial)
一键部署LAMP和LNMP架构
2022-07-09 group 5 Gu Xiangquan's learning notes day02
Burp suite Chapter 3 how to use burp suite agent
一点一点理解微服务
vim跨行匹配搜索
2022-07-08 group 5 Gu Xiangquan's learning notes day01
Official Oracle document
Basic configuration of BGP