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

122
Vistas
Use array to render select options

This should be straitforward thing but I cannot get to work even i tried different apporaches and also refered the stackoverflow existing solutions. I'm new to frontend work. I have react app (using typescript) and I'm using antd componets. I have following object

class User {
     locations: Location[];
}
class Location {
      name:string;
}

I want to render location names in select options. I tried

      <Select
            id="location"
            placeholder="Location"
          >
            {user.locations.map((loc) => {
              console.log('got -> ' + loc.name);
              <Option value={loc.name}>{loc.name}</Option>;
            })}
          </Select>

I get the exepected console log but nothing is rendered ( empty options list ) and there is no error. How to get this working

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You aren't returning anything from your map function, so it's just running and returning void. Since no component is returned, none is rendered. If you have multiple lines of code in an arrow function you have to use an explicit return. To quote MDN, (arrow functions do not magically guess what or when you want to "return")

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

about 4 years ago · Juan Pablo Isaza Denunciar
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