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

176
Visualizações
How to a drop down-down menu list

I am trying to do a dropdown menu in javascript where get all states from a function and show in the drop down menu. But the code that I have so far is showing my list wrong. Every state is next to each other instead of inside the drop down menu.

menu.js


export default function DropDownMenu(props){
    if(!props.states) return
    return(
        <table>
            <body>
                {props.states.map(states=>
                <select>
                    <option>{states.state}</option>
                </select>)}
            </body>
        </table>
    )
}

What is showing:

enter image description here

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

0

The problem is that you are wrapping the select element within the map, try to do the following:

export default function DropDownMenu(props){
    if(!props.states) return
    return(
        <table>
            <body>
             // to select the value from option, just add the onChange listener
             <select onChange={(e) => { console.log(e.target.value) }}>
                {props.states.map(states=>
                  <option>{states.state}</option>
                )}
             </select>
            </body>
        </table>
    )
}

That way you will just render dynamically the option element.

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