Skip to content
Discussion options

You must be logged in to vote

It's perfectly fine to manipulate the react-query cache by something you get via the websocket. After all, it should be the same as your current server state. This is similar to updates from mutation respsonses.

Another approach is to send "commands" via the websocket that instructs the queryClient to invalidate and thus refetch certain queries if something changes. I've written about that here: https://tkdodo.eu/blog/using-web-sockets-with-react-query

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jayporta
Comment options

Answer selected by jayporta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants