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

81
Vistas
React native: Handling state with lots of data

I am making a simple social media app in React Native. In my Feed screen, I am fetching data from my API, storing the array of objects in a posts state, and using a Flatlist to render Post components. I have other screens like PostDetail that I navigate to when a Post is pressed.

The more complex my app gets the harder it gets to manage the posts state that contains all the data required to display posts in the Feed. I find it especially awkward to update that state from other screens like PostDetail; when a user likes the post, comments on the post, etc.

I tried using React's Context API to store posts as a "global" state. That way I had access to the posts state in every screen. But whenever I would update the state it caused the entire app to re-render. Another thing: I find that creating a new posts object is very inefficient when only 1 item needs to be updated. This comes from the notion that state should be immutable in React.

// what if 'posts' is an array of 100+ items? This seems inefficient
const updatedPosts = posts.map(post => (
   post.id === newPost.id ?
   {
      ...post,
      likes: newPost.likes,
      comments: newPost.comments
   } : post
));

setPosts(updatedPosts);

Is there a better way of handling states with lots of data? I've heard that Redux can solve problems like this, but I want to avoid using it unless I really need to.

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