You can achieve this by using the filter method to remove duplicate signatory names before mapping them. Here's an updated version of the code:

if (!Array.isArray(list)) return '';
return list.map((item) => {
  const uniqueSignatories = item.signatories.filter((signatory, index, array) => {
    return array.findIndex((s) => s.signatoryName === signatory.signatoryName) === index;
  });

  return uniqueSignatories.map((signatory) => (
    <span>{signatory?.signatoryName}</span>
  ));
});

This code filters out duplicate signatory names using the filter method along with the findIndex method. The findIndex method checks if the current signatory's name has already been encountered before in the array. If it hasn't, it returns the current index, indicating that it is the first occurrence. Only the signatories with unique names are then mapped and returned as a list of <span> elements.

if !ArrayisArraylist return ;			return listmapitem = 				itemsignatoriesmapi = 					spanisignatoryNamespan				 当signatoryName的值一样则显示一个就可以

原文地址: http://www.cveoy.top/t/topic/jfzZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录