Too Long; Didn't Read
A few days ago I’ve built a React application with socket.io. I noticed that on a lot of messages my app starts to be slow and do some lag spikes. I used callbacks that didn’t help a lot because I had almost all of the state at the root of the app and I basically killed the memoization. After some I did some search on Google, and I found an article with a developer who had the same issue. The awarded response was to use socket.off into the cleanup function of useEffect. After I tried this one, all the apps worked like a charm.