Пример #1
0
 constructor (props) {
   super(props);
   this.state = {messages: []};
   this.socket = new WebSocket('ws://localhost:8888/ws/test');
   this.socket.onmessage((msg) =>{
     this.state.messages.push(msg);
     this.forceUpdate();
   });
 }
Пример #2
0
 onSubmiting(text) {
   this.socket.send(text);
   this.setState({messages: this.state.messages});
 }