React Query frequent cache updates

Hey everyone, I’m working on a React chat app and using React Query for data. Basically, I fetch the conversations list and messages from two separate APIs at first, but after that, all interactions (like new messages, unread counts, etc.) are handled through WebSockets (inbound and outbound). Right now, I’m using setQueryData to update the React Query cache whenever a WebSocket event happens so the UI updates immediately (like appending messages or updating the last message in a conversation). It works, but I’m wondering if this is the best approach? It feels like it might get slow or messy with a lot of updates. Is there a better way to handle frequent WebSocket updates with React Query?
3 Replies
wb-ts
wb-ts5w ago
Your current solution is good , and I would like to talk you about throttling more.
Ov3rControl
Ov3rControlOP5w ago
@wb-ts I would love that
wb-ts
wb-ts5w ago
Thanks for considering my opinion.

Did you find this page helpful?