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

120
Visualizações
Chakra UI unique key prop

I am using @chakra-ui/react version 1.7.2 in my React 17.0.2 project.

This version of Chakra UI is supposed to have solved the issue of having unique keys in its elements, but I am still having the error when I test the code and in Chrome's console:

"Each child in a list should have a unique "key" prop."

Adding a unique "key" prop manually doesn't solve the issue. Any suggestions?

    const MyComponent = () => {
        const myArray = ['London', 'Paris'];
        
        return (
          <List>
            {myArray.map(city => (
                <ListItem key={city}>
                  <b>{city}</b>
                </ListItem>
              )
            )}
          </List>
        )
    };
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

if you have id in side the city object assign that like city.id etc. if not you can assign some unique string on the city object that is being returned. The only last resort is to use the index number of the item (it is not suggested but you can use it.). See the code below:

      <List>
        {myArray.map((city, index) => (
            <ListItem key={index}>  <=========== (you can use city.<some_unique_id_here>)
              <b>{city}</b>
            </ListItem>
          )
        )}
      </List>
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