title: Set up React component to listen to socket.io
body: <p>I want my React component to listen to events from socket.io. My code works if I have the HTML files include:</p>
  
  <p><code>&lt;script src="socket.io/socket.io.js"&gt;&lt;/script&gt;</code></p>
  
  <p>and then the component's constructor() has: </p>
  
  <p><code>this.socket = io(); // eslint-disable-line no-undef</code></p>
  
  <p>The HTML file retrieves the proper socket.io client code from my Express server, and everything's fine.</p>
  
  <p>But this feels so cheesy. I hate to rely on the global window name space to find the io() function. What's the best practice for letting a React component connect through socket.io to the server? Thanks.</p>