Support for React.JS
From documents, its not clear how to use this library in React.JS (in ES6)
Please drop a example about the same
It works like any other Node.js package. In the browser you have to use the native WebSocket object not ws.
@lpinca Thanks
An example would help (it can be incorporated to this if needed as Pull Request https://github.com/rajiff/ws-react-demo)
That means, in WS we also don't have support for any channel/room/namespace concept?
That means, in WS we also don't have support for any channel/room/namespace concept?
Yes, that's correct.
As for the examples, there are a lot of results if you search "react websocket example" on google.
@lpinca : I update my repo now with working version, please have a look and suggest
What is the suggestion if we want to send data to specific client sockets only? only emit on that socket object alone?
Here's another example; I'm using the React Context API to share the connection between all components:
https://github.com/DestinyTheGame/anubis/blob/master/components/websocket/index.js
Thanks @3rd-Eden
I now got it updated https://github.com/rajiff/ws-react-demo/blob/master/public/components/WebSocketClient.jsx, a fully functional react ws client with 'WS' as server
Going to try this with socket.io also as i need pvt channels/rooms