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

112
Vistas
Component inside renderList in a FlastItem remounting after calling setState

I'm passing a component to the renderItem. Inside the component I have a state and i make a call to the api that will update this state with the response.

But what is happening is, it renders loading... then it actually shows what the api returned, goes back to showing loading and then goes back to showing what the api returned.

For example: if the searchDescriptionById function returns description 1, what is rendering on the screen is: loading... -> description 1 -> loading... -> description 1

as if at the first setState the component is remounting


const Component= ({ item }) => {
      const [description, setDescription] = useState('loading...');
      useEffect(() => {
        searchDescriptionById(item.id).then(res => {
          setDescricao(res);
        })
      }, [])
      return (
          <TouchableOpacity style={{ flex: 1 }}>
            <Textbold>{item.id}</Text>
            <Text>{description}</Text>
          </TouchableOpacity>
      )
  }

<FlatList
 data={data}
 contentContainerStyle={{ paddingBottom: 10 }}
 keyExtractor={item => item.id}
 renderItem={({item}) => <Component item={item}/>}
about 4 years ago · Juan Pablo Isaza
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