Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!