I'm working on a chat application using react, redux and socket.io. As we know, redux is very helpful to pass down some state to deep and nested components. I like this idea to store some props as a redux state which will be passed down to some heavily nested component. I'm using socket.io-client library to create the socket object.
I need to pass down the created socket object to some heavily nested components so, I was thinking of creating the socket object on the redux state so that I can consume it easily on the nested components.
Is this a good approach or should I be doing something else?
No, it's not.
We recently added a Redux FAQ entry on where websockets should live in a Redux app. Quoting that entry: