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

88
Visualizações
React Native FlatList Rerender Problems

So I have this selection FlatList where the user can select a country. When I press on a item it's going to take a second and after the second it is displaying the checkmark.

The Problem is the second. The user cannot wait a second to see that the country was selected.

<FlatList
  keyExtractor={item => item.countryid}
  data={countryChoices}
  renderItem={({item}) => {
    return(
      <CountryComponent                                       
        item={item}
        conditionToCheck={country == item.countryname}
        onPress={() => setCountry(item.countryname)}
      />
    )
  }}
/>

This is my Flatlist. countryChoices is just an array with different objects for the countries. the conditionToCheck checks wether to show or to hide the checkmark. If the selected Country is equal to the item then it's going to show the checkmark.

But after clicking on it it's taking too long :/

I also tried wrapping the FlatList Item in a useCallback but it wasn't (much) faster

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try passing country as extraData in you FlatList since country is outside of data prop

<FlatList
  keyExtractor={item => item.countryid}
  data={countryChoices}
  extraData={country}
  renderItem={({item}) => {
    return(
      <CountryComponent                                       
        item={item}
        conditionToCheck={country == item.countryname}
        onPress={() => setCountry(item.countryname)}
      />
    )
  }}
/>

extraData is a marker property for telling the list to re-render (since it implements PureComponent). If any of your renderItem, Header, Footer, etc. functions depend on anything outside of the data prop, stick it here and treat it immutably.

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