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

257
Visualizações
Each child in a list should have a unique "key" prop. but i'm not calling any component

if i call all discount price using map method. it perfectly work but i see in console and like this error are found. how to fix it

 <div className="priceCal flex flex-col items-center">
       <p style={{ fontSize: '1.5em' }} className='font-medium pt-3'>Total items: </p>
          {
            data.map((v, i)=>{
            return <p className='font-bold text-xl'>Rs. {v.DiscountPrice}</p>
             })
         }
</div>

Click to view the error



react-jsx-dev-runtime.development.js:117 Warning: Each child in a list should have a unique "key" prop.

Check the render method of `Cart`. See https://reactjs.org/link/warning-keys for more information.
    at p
    at Cart (http://localhost:3000/static/js/bundle.js:3393:74)
    at Routes (http://localhost:3000/static/js/bundle.js:63733:5)
    at RouterMenu
    at App (http://localhost:3000/static/js/bundle.js:140:81)
    at Router (http://localhost:3000/static/js/bundle.js:63666:15)
    at BrowserRouter (http://localhost:3000/static/js/bundle.js:63146:5)
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You need to add a key to the parent element of the return like this

return <p className='font-bold text-xl' key={i}>Rs. {v.DiscountPrice}</p>

But it's better to use a unique property of the object like key={v.id} if id exists

about 4 years ago · Juan Pablo Isaza Relatório

0

You are looping over

data.map((v, i)=>{
        return <p className='font-bold text-xl'>Rs. {v.DiscountPrice}</p>
})

Just add a key to the return JSX

data.map((v, i)=>{
        return <p key={i} className='font-bold text-xl'>Rs. {v.DiscountPrice}</p>
})

If you have a unique identifier in the v object, use that

Refer => https://reactjs.org/docs/lists-and-keys.html#keys

about 4 years ago · Juan Pablo Isaza Relatório
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