在使用Table标签中自定义render,例如:
运行结果报错:Component definition is missing display name react/display-name
const columns = [
{
title: 'Tags',
key: 'tags',
dataIndex: 'tags',
render: tags => (
<>
{tags.map(tag => {
let color = tag.length > 5 ? 'geekblue' : 'green';
if (tag === 'loser') {
color = 'volcano';
}
return (
<Tag color={color} key={tag}>
{tag.toUpperCase()}
</Tag>
);
})}
</>
),
}
]
解决方案:
将.eslintrc.json中rules中加入"react/display-name": “off”
// eslintrc.json
{
"rules": {
"react/display-name": "off"
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)