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

191
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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