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

129
Vistas
lit element unable to render in for each loop

I'm having an object property like so

pageSizeValues: {
  type: Object
}

that is being instantiated like this

this.pageSizeValues = {10: 10, 25: 25, 50: 50};

Based on it I'd like to build a dropdown with 3 entries, that is by iterating over the pageSizeValues

<vaadin-select @change="${event => this.setLimit(event.target.value)}" value="${this.limit}" placeholder="Page Size" style="width: 80px">
  <template>
    <vaadin-list-box>
      ${Object.entries(this.pageSizeValues).forEach(([key, val]) => 
          {   console.log(key + " " + val);
              html`
                <vaadin-item value=${key}>${val}</vaadin-item>
                 `
            })}
    </vaadin-list-box>
  </template>
</vaadin-select> 

While the console.log properly display the key-value pairs in the UI I'm not getting the items rendered at all.

I managed to render the items properly when the I was iterating over an array instead of an Object so I'm not sure where the issue might be.

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

0

You need to return the html value or it is just created and discarded. The easiest way is to use map instead of forEach

      ${Object.entries(this.pageSizeValues).map(([key, val]) => 
          {   console.log(key + " " + val);
              return html`
                <vaadin-item value=${key}>${val}</vaadin-item>
                 `
            })}
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