title: Component not re-rendering after state change
body: <p>Here is my SalesOverview1 component. I'm making an axios request after the user clicks on the Sales Overview tab. The code for the onClick handler is in the parent component where I update the state to indicate that a click has been made, I basically change the state to true. And then I conditionally render the SalesOverview1 component based on the click and then inside componentDidMount, I make the axios request. I'm not able to see the chart on the 1st click even though data is being fetched. But when I click on another tab and then click back on the Sales Overview tab, I can see it.</p>
  <pre><code>class SalesOverview1 extends Component {
  
  state = {
      page_id: 4,
      hcp_id: 101,
      sales_overview_data: []
  }
  
  componentDidMount() {
      console.log('Clicked on sales Overview!');
      let page_id = this.state.page_id;
      let hcp_id = this.state.hcp_id;
      console.log('state: ', this.state);
      axios.post('/test-json', {
          page_id: page_id,
          hcp_id: hcp_id
      })
          .then((res) =&gt; {
              const dataRequest = res.data;
              console.log('State before loading data in sales overview: ', this.state);
              console.log('received data inside sales overview', res.data);
              this.setState({ ...this.state, sales_overview_data: res.data });
              console.log('State after loading data in sales overview: ', this.state);
              // this.props.salesOverviewDataFromParent(this.state.sales_overview_data);
              this.forceUpdate();
          }, (error) =&gt; {
              console.log(error);
          });
  }
  
    return(
      &lt;&gt;
        &lt;div role=&quot;tabpanel&quot; id=&quot;tablet-3&quot; class=&quot;tab-pane&quot; &gt;
                  &lt;div class=&quot;panel-body&quot; style={{ backgroundColor: &quot;rgb(243,243,244)&quot;, border: &quot;none&quot;, margin: 0 }}&gt;
        &lt;div class='row'&gt;
           {
                              this.state.sales_overview_data.length !== 0 &amp;&amp;
                              &lt;ChartBox
                                  data={this.state.sales_overview_data[401]}
                              /&gt;
                          }
        &lt;/div&gt;
         &lt;/div&gt;
         &lt;/div&gt;
  </code></pre>
  <p>This component is being triggered like this in the parent Search component:</p>
  <pre><code>   class Search{
       state={
        sales_overview_clicked: false
       }
          ...
        salesOverviewButtonClicked = () =&gt; {
      this.setState({ ...this.state, sales_overview_clicked: true })
       }
  
      return(
         &lt;div&gt;
            &lt;ul class=&quot;nav nav-tabs&quot; role=&quot;tablist&quot;&gt;
                &lt;li&gt;&lt;a class=&quot;nav-link &quot; data-toggle=&quot;tab&quot; href=&quot;#tablet-3&quot; onClick={this.salesOverviewButtonClicked}&gt; &lt;i class=&quot;fa fa-bar-chart-o&quot;&gt;&lt;/i&gt;Sales Overview&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
           &lt;div class=&quot;tab-content&quot;&gt;
               {this.state.sales_overview_clicked === true &amp;&amp; &lt;SalesOverview1 /&gt;}
            &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  <p>I've kept only the relevant code and deleted the unnecessary code.</p>
  <p>A visual of how the Sales Overview tab looks like:</p>
  <p><a href="https://i.stack.imgur.com/vH7Qj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vH7Qj.png" alt="enter image description here" /></a></p>