Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!