Attempted import error: 'Icon' is not exported from 'antd'

Mushood Hanif picture Mushood Hanif · Mar 14, 2020 · Viewed 12.3k times · Source

I have created a react app using 'create-react-app' and in one of my project files, i'm using the following import statement;

import { Icon } from 'antd',

and receiving the following error:

Attempted import error: 'Icon' is not exported from 'antd'.

not sure what the issue is. please help.

Answer

Agney picture Agney · Mar 15, 2020

On upgrading the version of Ant Design to v4, one of the major breaking changes have been that Icon is no longer exported from antd package.

Also instead of having string based icon references like:

// Before
<Icon type="smile" />

In v4:

import { SmileOutlined } from '@ant-design/icons';

<SmileOutlined />

There is still an Icon export, but that is from the package @ant-design/icons instead of just antd. This Icon export can be used for adding custom icons.

Docs Changelog