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.
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.
i've installed the ant design package using "npm i -D antd", and this import statement, "import { Icon } from '@ant-design/icons' is not working. should i remove and install the package with a different command ? how should i go about it ?
Yes, thank you, your solution worked, i had to separately do
npm i -D @ant-design/icons
and then had to import each icon separately. thank you for your help bro.-D
is for installing a developer dependency, unless you intend to add it as a library, you don't require it