poopinurass..verybigpoop
poopinurass..verybigpoop
TTCTheo's Typesafe Cult
Created by poopinurass..verybigpoop on 11/25/2023 in #questions
Updating single item in list (liking a post) - syncing state with server
I have a standard social media app to test some technologies out. I fetch all the posts, which come in an array from the server. How should I correctly go about syncing the state with the server after user likes a post? I don't want to invalidate the query which fetches all posts - as I don't want to fetch more posts at the top if they were added in the meantime. I just want to update that one post which came in an array. What is the correct approach to solve this? How does Facebook do it, that if you have the post opened in a modal and like the post, it is still reflected after you close the modal? This would also be a relevant question with websockets and push notifications signaling that the post was liked - I want to increment the amount of likes only on that one post.
2 replies