reactjs - 应用 find() 时获得 2 个渲染而不是 1 个渲染
问题描述
我想在 Link 中获取一些值,使用 ant design,table 组件。在 ant design 中渲染一个值:
{
title: 'Action',
key: 'action',
render: (text, record) => (
<span>
<a style={{ marginRight: 16 }}>Invite {record.name}</a>
<a>Delete</a>
</span>
),
},
];
我使用上面的示例编写了代码:
{
title: 'Animal',
dataIndex: 'animal',
key: 'animal',
render: () => (
<Link>{
animals.filter(id => id.animal_id === myId).map((item, i) =>{
return <a href="">{myArray.find(u => u.id === item.myarray_id).name} </a>
})
}
</Link>
),
},
)
问题是,我明白了:
dogdog
catcat
// the output values are doubled
为什么我得到重复的值?
解决方案
推荐阅读
- ios - 在表格视图的自定义单元格上隐式展开可选值
- c# - 你能传递一个动态命名的委托 Func<> 参数吗?方法(“FunddelegateNameOfMethod”)
- c# - ComboBox 中的 SelectedItem 绑定
- swift - Swift AVSpeechSynthesizer Text to Speech 在 iOS 中不起作用
- java - 服务器端异步和同步HTTP请求,性能对比
- google-cloud-build - Google Cloud Builder 中同一构建步骤中的多个命令
- xcode - 为什么我的 XIB 视图显示为正方形?
- excel - 根据日期复制单元格范围并粘贴到另一个工作表中?
- git - 列出在一次提交到远程分支中更改的文件
- javascript - 文本框上 ng-change 的高效/单次触发