title: react + socket.io emits not going through - basic error
body: <p>There must be a simple mistake in my understanding of reactjs or socket.io. I have a server that sends "speed" values iterating from 2 to 5, and a client that receives them and displays them.</p>
  
  <p>The issue:</p>
  
  <p><strong>Expected behavior:</strong> client displays numbers iterating from 1 to 5 every second and stops at 5. Client logs that it has received 4 messages with updated speed value (a new message every second)</p>
  
  <p><strong>Actual behavior:</strong> client displays a speed of 1. Client waits 4 seconds. Client displays a speed of 5 and, in that moment, logs having received the 4 messages with iterating speed from the server.</p>
  
  <p>What is the issue? It's almost as if the server is sending all 4 speed messages at the same time.</p>
  
  <p>Client code:</p>
  
  <pre><code>import React from 'react';
  import {CircleGauge} from 'react-launch-gauge';
  import io from 'socket.io-client';
  
  class App extends React.Component {
      constructor(props, context) {
          super(props, context)
          this.state = {
              speed: 1
          };
      }
      componentDidMount() {
          const socket = io('http://localhost:5000');
          socket.on('data update', data =&gt; 
              this.setState( { speed: data }, 
                  () =&gt; console.log("got the speed: " + this.state.speed)));
          socket.open();
      }
  
      render() {
          return (
              &lt;div&gt;
                  &lt;p&gt; The velocity received is: {this.state.speed}  &lt;/p&gt;
              &lt;/div&gt;
          );
      }
  }
  export default App;
  </code></pre>
  
  <p>Server Code:</p>
  
  <pre><code>from flask import Flask, render_template
  from flask_socketio import SocketIO, emit
  import time
  
  sendData = False;
  
  app = Flask(__name__)
  socketio = SocketIO(app)
  
  @socketio.on('connect')
  def dataSent():
      print('they connected**********************************')
      for i in range(2,6):
          socketio.emit('data update', i)
          time.sleep(1)
          print(i)
  
  
  if __name__ == '__main__':
      socketio.run(app, debug = True)
  </code></pre>