title: React native and socket.io node not working
body: <p>Below is my react native component and node server.js code  that I am trying to connect to my node websocket backend.</p>
  
  <p>My react code is running on the same computer as the server. I have found so many varying answers on here, and github, none of which I can get working.</p>
  
  <p>I also found this <a href="https://stackoverflow.com/questions/37505661/react-native-with-socket-io-doesnt-work?rq=1">question</a> which was never answered, and <a href="https://stackoverflow.com/questions/29408492/is-it-possible-to-combine-react-native-with-socket-io">this question</a> has an answer, which I cannot get working (was asked over a year ago)</p>
  
  <p>I have found <a href="https://medium.com/@ekryski/how-to-actually-use-socket-io-in-react-native-39082d8d6172" rel="noreferrer">this article</a> and tried to amend my code based on these guidelines but this did not work.</p>
  
  <p><strong>react code</strong>  </p>
  
  <pre><code>import React from 'react';
  import { StyleSheet, Text, View, Image } from 'react-native';
  
  const io = require('socket.io-client/socket.io');
  let socket = io('http://localhost:3000');
  
  export default class App extends React.Component {
  
      constructor(props) {
          super(props);
          console.log(socket);
      }
  
      render() {
          return (
              &lt;View&gt;
                  &lt;Text&gt;Websocket&lt;/Text&gt;
              &lt;/View&gt;
          );
      }
  }
  </code></pre>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>const express = require('express');
  const http = require('http')
  const socketio = require('socket.io');
  
  const app = express();
  const server = http.Server(app);
  const websocket = socketio(server);
  server.listen(3000, () =&gt; console.log('listening on *:3000'));
  
  console.log(websocket)
  
  // The event will be called when a client is connected.
  websocket.on('connection', (socket) =&gt; {
    console.log('A client just joined on', socket.id);
  });
  </code></pre>
  
  <p>I am using the following versions of packages</p>
  
  <pre><code>"expo": "^16.0.0",
  "react": "16.0.0-alpha.6",
  "react-native": "^0.43.4",
  "socket.io-client": "^1.7.3"
  </code></pre>