Replies: 2 comments 1 reply
-
Hi! This article explains how you can use React Query with WebSocket. You should be able to convert it to Socket.IO, something like: const useReactQuerySubscription = () => {
const queryClient = useQueryClient()
React.useEffect(() => {
const socket = io('<the server url>')
socket.on('connect', () => {
console.log('connected')
});
socket.on('entity:update', (queryKey) => {
queryClient.invalidateQueries({ queryKey })
});
return () => {
socket.disconnect()
}
}, [queryClient])
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
do you succed? if yes, could u share ur repo i wanna see it:) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Team,
I need to cache my socket emit request using TanStack query to improve perfomance and cost reduction.
Can you guide me how to use TanStack query with Socketio or is there any way to cache socket io emit requests.
Thanks
Vinal Patwa
Beta Was this translation helpful? Give feedback.
All reactions