title: How to connect to an MQTT broker in React-Native?
body: <p>I am trying to integrate MQTT into my app. I was reading <a href="https://stackoverflow.com/questions/54764123/how-to-use-mqtt-on-react-native/58153168#58153168">this post</a>, but I can't connect to the broker due to either using an outdated React Native MQTT library or my code being wrong. How can I successfully connect to a broker?</p>
  
  <pre class="lang-js prettyprint-override"><code>import init from 'react_native_mqtt';
  import { AsyncStorage } from 'react-native';
  
  init({
    size: 10000,
    storageBackend: AsyncStorage,
    defaultExpires: 1000 * 3600 * 24,
    enableCache: true,
    reconnect: true,
    sync : {
    }
  });
  
  const client = new Paho.MQTT.Client(
    "m23.cloudmqtt.com", 
    18628,
    "clientID-" + parseInt(Math.random() * 100)
  );
  
  client.connect({ 
    useSSL: true,
    userName: "username",
    password: "password"
  });
  
  function onConnect() {
    client.subscribe("topic");
  }
  </code></pre>