I have a component that updates the state when a socket message is received. It looks like this:
SocketComponent.js