title: SignalR hub.On methods work after refreshing the page
body: <p>I have this code on ReactJS and SignalR. The SignalR On methods works only after page refresh. Please explain me how to solve this problem.</p>
  <pre><code>componentDidMount() {    
      const connection = new HubConnectionBuilder()
        .withUrl('http://test.com/hub', { accessTokenFactory: () =&gt; Cookies.get('access_token') })
        .configureLogging(LogLevel.Debug)
        .withAutomaticReconnect([0, 0, 2000])
        .build();
  
      connection.on('MessageCount', () =&gt; someMethod());
      connection.on('Dialog', () =&gt; someMethod());
      connection.on('Send', () =&gt; someMethod());
      connection.start().then(() =&gt; console.log('Connected'));    
     
    }
  </code></pre>