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(); }); }
onSubmiting(text) { this.socket.send(text); this.setState({messages: this.state.messages}); }