Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda