Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Icon should have `type` prop or `component` prop or `children`?

Warning: Icon should have `type` prop or `component` prop or `children`. 
How to troubleshoot the issue?

import React from 'react';
import { bindActionCreators,createStore } from 'redux';
import { Link, browserHistory } from 'react-router';
import { connect } from 'react-redux';
import actions from '../../actions/information/inforResource.js';
import Dropdown from '../../components/common/dropdown.js';
import ListSearch from '../../components/common/listSearch.js';
import moment from 'moment';
import {Modal, Icon, Button, Row, Col, Form, DatePicker, Select, Table, Input, Pagination, Menu, Tooltip, Drawer, message, Avatar} from 'antd';

<Icon type="delete"/>

I deleted the icon tags of the page and still reported an error. I deleted the Icon tag in the subcomponent and still reported an error.

react.development.js?99ee:335 
Warning: Icon should have `type` prop or 
`component` prop or `children`.
printWarning       warning.js?bcd6:34
warning            warning.js?bcd6:57
_default           warning.js?fe52:16
Icon               index.js?be01:80
renderWithHooks    react-dom.development.js?cada:12938
mountIndeterminateComponent  react-dom.development.js?cada:15020
beginWork          react-dom.development.js?cada:15625
like image 795
Ri Sheng Deng Avatar asked Nov 17 '22 02:11

Ri Sheng Deng


1 Answers

Solution is to import icon directly.

import -

import DeleteOutlined from '@ant-design/icons/DeleteOutlined';

call -

<DeleteOutlined />

'antd' version in package.json -

"dependencies": {
    @ant-design/icons": "^4.7.0",
    "antd": "^4.19.5",
}
like image 69
Pinaki Avatar answered Jan 14 '23 10:01

Pinaki