title: signalR connection.hub function not called in react component
body: <p>I'm creating a chatboard and I'm using signalR to let users know when new comment is added on some status/post.</p>
  
  <p>I'm using React and I've tried to add event listeners for the hub function in different components, in some components it works, not others.</p>
  
  <p>This is the hub:</p>
  
  <pre><code>public class CommentHub : Hub
  {
      public void UpdateComments(int postId)
      {
          try
          {
              var context = GlobalHost.ConnectionManager.GetHubContext&lt;CommentHub&gt;();
              context.Clients.All.updateNewComments(postId);
          }
          catch (Exception ex)
          {
              Log.Error(ex.Message);
          }
      }
  }
  </code></pre>
  
  <p>I call the event listener in the componentDidMound function:</p>
  
  <pre><code>componentDidMount: function() {
      this.commentUpdateListener();
  },
  </code></pre>
  
  <p>And this is the event listener:</p>
  
  <pre><code>commentUpdateListener: function () {
      console.log("in the comment update listener!");
      var commentHub = $.connection.commentHub;
  
      commentHub.client.updateNewComments = function (postId) {
          console.log("updateNewComments called!");
      };
  
      $.connection.hub.start();
  },
  </code></pre>
  
  <p>I have a react component for a post/status, a component for the "wall/newsfeed" and then I have a component for the "comment box" for each status on the wall, where the comments are rendered.</p>
  
  <p>When I place the event listener in the wall component or the post component it works, and the 'updateNewComponent' function gets called, but not when I place it in the "comment box" component.</p>
  
  <p>Still "in the comment update listener!" gets logged no matter where I place the event listener, but the hub function is not always called, and it seems to matter in what react component the event listener is placed.</p>
  
  <p>Is the $.connection.commentHub not staying alive? Is it closing?
  Is there some reason the function is not always being called?</p>