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

195
Vistas
React Native, FlatList does not output my list correctly

I have this quite easy items where I normally loop over with map:

{items.map((item, index) => {
  return (
    <Item
      desc={item.desc}
      done={item.done}
      index={index}
      key={index}
      onSetDone={setDone}
    />
  );
})}

The above code works fine, but as I learned, it is better do use FlatList in my components do render something in a loop. So I tried the following:

<FlatList
  data={items}
  renderItem={(item, index) => (
    <Item
      desc={item.desc}
      done={item.done}
      index={index}
      onSetDone={setDone}
    />
  )}
  keyExtractor={(item, index) => index}
/>

The correct amount of items are rendered, but unfortunately, none of the props gets passed to the Child component. Getting undefined undefined true.

What am I doing wrong here? Why is my data not correctly passed?

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

0

You are not giving renderItem a function with the right parameter. Here is its signature from the doc:

renderItem({ item, index, separators })

Change your code to this:

<FlatList
  data={items}
  renderItem={({ item, index }) => (
    <Item desc={item.desc} done={item.done} index={index} onSetDone={setDone} />
  )}
  keyExtractor={(item, index) => index}
/>
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