title: How to fix scope problem inside "then" function react?
body: <p>I am trying to print out of Printer. I am a little new to react and javascript. I am trying to pass the state to a then function of Third Party Code. But i am getting an error:</p>
  
  <pre><code>Cannot read property 'restaurant_name' of undefined
  </code></pre>
  
  <p>How can i pass <code>state</code> to the scope of <code>then</code> function of <code>qz</code>?</p>
  
  <pre><code>print = () =&gt; {
      let { state } = this.state;
      qz.websocket.connect()
      .then(function() {
       return qz.printers.find("BillPrinter");
     }).then(function(printer) {
           var config = qz.configs.create(printer);
           var data = [
                `${state.restaurant_name}` + '\x0A',
                `${state.restaurant_address}`
           ]
  
           return qz.print(config, data);
      });
  }
  </code></pre>