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

121
Visualizações
Fill select with array of object

I have this result from my firebase in a variable :

[
    {
        "value": "CHProNd9BGYznrEr0u43",
        "label": "Jean"
    },
    {
        "value": "Huo0mofwJGKx2uEd9467",
        "label": "aaa"
    },
    {
        "value": "IO5w6WstNngCNyKRneYg",
        "label": "African"
    }
]

I get this result with this call to firebase :

export async function getCoupeurs() {

      let getCoupeurFromFirebase = [];
          const coupeursRef = collection(db, "coupeurs");
          getDocs(coupeursRef).then(snapshot => {
          snapshot.forEach(doc => {
              getCoupeurFromFirebase.push({
              value: doc.id,
              label: doc.data().nom,
              });
          });
        });
    
        return getCoupeurFromFirebase;
    }

and i want to fill this select input :

<select>
{ 
  coupeurs.map(coupeur => (
    <option key={coupeur.value} value={coupeur.value}>{coupeur.label}</option>
  ))
}
</select>

but i have nothing on my screen and no error, can you help me to do this by the best way ? [updated] The code on codepen.io , that work so i think the problem is the call for data from database there is a way to tell that i want to wait the result before send the data to my component ?

https://codepen.io/lbain/pen/ENpzBZ

<select>
          {
            coupeurs.map(coupeur => (
              <option>{coupeur.label}</option>
            ))
          }
</select>

thanks.

about 4 years ago · Santiago Gelvez
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