TanStackT
TanStack13mo ago
2 replies
awake-maroon

RQ frequent cache updates using WebSockets

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?
Was this page helpful?