title: Usage of MQTT protocol in React
body: <p>I'm kinda new to react and trying to understand how to make MQTT work with it.</p>
  
  <p>i've tried to follow the code sample published here: <a href="https://www.npmjs.com/package/mqtt-react" rel="nofollow noreferrer">https://www.npmjs.com/package/mqtt-react</a></p>
  
  <p>but had no success.
  for some reason it's just don't do anything.</p>
  
  <p>here's my code:</p>
  
  <p><strong>App.js class:</strong></p>
  
  <pre><code>import React, { Component } from 'react';
  import './App.css';
  import PostMqtt from './PostMessage.js';
  import {Connector} from "mqtt-react";
  
  class App extends Component {
      render() {
          return (
              &lt;div className="App"&gt;
                  &lt;PostMqtt/&gt;
              &lt;/div&gt;
          );
      }
  }
  
  export default () =&gt; (
      &lt;Connector mqttProps="ws://test.mosquitto.org/"&gt;
          &lt;App /&gt;
      &lt;/Connector&gt;
  );
  </code></pre>
  
  <p><strong>PostMessage.js class:</strong></p>
  
  <pre><code>import React from 'react';
  import { subscribe } from 'mqtt-react';
  
  export class PostMessage extends React.Component {
  
      sendMessage(e) {
          e.preventDefault();
          //MQTT client is passed on
          const { mqtt } = this.props;
          mqtt.publish('sensor', 'My Message');
      }
  
      render() {
          return (
              &lt;button onClick={this.sendMessage.bind(this)}&gt;
                  Send Message
              &lt;/button&gt;
          );
      }
  }
  
  export default subscribe({
      topic: 'sensor'
  })(PostMessage)
  </code></pre>
  
  <p>Any ideas what goes wrong?
  thanks!</p>