Like and save in paginated list

I am building a social media application on React.js. So on the homepage, I am showing a list of products. for those posts, features I want to achieve:-

  1. Let’s say X is a post and user Y like the post, so X contains a key called liked, initially liked: false. But when users like the post it should become true.
  2. When a user comes back to the application after some time, it should be liked: true by default for the current user.
  3. Similarly like Facebook, it behaves.

i tried to achieve it by comparing user like collection and post collection but that process it much expensive to. SO i need a optimised and fast way to achieve this feture.