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

108
Visualizações
Select option display many boxes instead of a single dropdown with the options

So in my server I have a list of places that I would like to chose in dropdown. So before anything I'm splitting the places because they're stored as a single string:

  const where = settings?.places.split(',')

This is my first try to show it as dropdown options, the problem is that it displays one option with all the places:

        <select>
          <option value={where}> {where}</option>
        </select>

The other option shows every option in a different box:

        {where?.map((site, index) => {
          return(
            <select key={index}>
            <option value={site}>{site}</option>
            </select>
          )
        })}

enter image description here

Image of reference.

Any help is appreciated

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Assuming this is inside a function component, simply move the select tag outside of the map function.

return (
  ...
  <select>
    {where?.map((site, index) => {
      return(
        <option key={index} value={site}>{site}</option>
      )
    })}
  </select>
)
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