Skip to content
Advertisement

Why React js receive multiple answer from server with Socket.io?

When emit a event to the websocket server, the server receive the event once and send a response, but the client receive the event multiple time: result expected result received client side:

JavaScript

server side :

JavaScript

Advertisement

Answer

UPDATE: on the client side I got to put the socket.on(‘response,()=>{…}) in the UseEffect of the component and add a socket.off in the return of the useEffect

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement