Hackernoon logoWhat I learned from building a chat project with sockets.io and React by@alexcloudstar

What I learned from building a chat project with sockets.io and React

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.
image

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.