DEV Community

loading...

Discussion on: A Socket.io tutorial that ISN'T a chat app (with React.js)

Collapse
captainpandaz profile image
Talha Muhammad Author

Hey! Sorry about the late response.

I'm going to assume that you're asking about where to put socket.on() on the client app (which im also assuming is in react).

I'm also going to assume you aren't using hooks since this tutorial did not have hooks (hooks are awesome btw)

If both of these are valid, you can add the "listener" to a components componentDidMount lifecycle method, just like I did above.

You can read more about the method here: reactjs.org/docs/react-component.h...