Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

103
Visualizações
Function not filtering

I have this function that is supposed to filter through a js array and show only items with the same category name for example "Top" and nothing is happening when i click the button.

Console sends this warning: Warning: Each child in a list should have a unique "key" prop.

const [data,setData] = useState(data);
    const filterResult = (categoryItem) =>{
        const result =data.filter((currData)=>{
            return currData.category === categoryItem;
        })
        setData(result);
    }
    return(
    <div>
      button onClick={()=>filterResult("Top")}>Top</button>
    </div>
 

                <div>
            {data.map((nftDetail)=>{
                return  (<>
                    <div className='card' key={nftDetail.id}>
                    <h3>{nftDetail.title}</h3>
                    <h5>{nftDetail.category}</h5>
                    </div>
                    </>)
                })}        
            </div>

)

Data used for the map

{
    id:1,
    title: "NFT",
    category:"Top"

},
{
    id:2,
    title: "2NFT",
    category:"Trending"

},
{
    id:3,
    title: "3NFT",
    category:"Art"

},
{
    id:4,
    title: "4NFT",
    category:"Sports"

},
{
    id:5,
    title: "5NFT",
    category:"Top"

}

]

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda