首页 > 解决方案 > 应用 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

为什么我得到重复的值?

标签: reactjs

解决方案


推荐阅读