title: How to call method with bind(this) inside a websocket event
body: <p>I am using React and Websocket to test communication:</p>
  
  <pre><code>class Class extends React.Component {
  
    constructor(props) {
      super(props);
      this.state = {...};
      this.generateMsg= this.generateMsg.bind(this);
      this.sendMsg = this.sendMsg.bind(this);
    }
  
    //generate a random array
    generateMsg(n) {return [...]}
  
    //websocket sendMsg
    sendMsg(){
      const wsClient = new Websocket(url);
      wsClient.onopen = function(){
        wsClient.send(this.generateMsg(40));
      }
    }
  
    render() {
      return (
        &lt;button onClick={this.sendMsg}&gt;{this.state.nameList}&lt;/button&gt;
      );
    }
  }
  
  ReactDOM.render(...);
  </code></pre>
  
  <p>always raises err "this.generateMsg is not a function", how to call a method with bind(this) inside a websocket event please?</p>