More optimize way to find whether user likes the post or not in infinite post feed

23 views Asked by At

I'm working on a React Native social media project, focusing on the post feed screen. I'm wondering about the most efficient way to determine whether a user has liked a post. In scenarios where there are thousands of likes for a particular post, the naive approach of iterating through all the likes and matching the userId can be quite costly, especially when dealing with multiple posts simultaneously. Any suggestions on optimizing performance would be greatly appreciated.

For optimization I am rendering 10 posts at a time and cached them and when user scroll down, next 10 records will be fetched, but I am wondering is there still a better approcah to tackle this problem.

I am using Firebase for storage now

0

There are 0 answers