title: React app not showing data from api when setting state in componentDidMount
body: <p>I have some react code where i'm trying to show a list of data in a table. This is the code. The console.log call in the getPagedData displays the correct results in the console but the render is not showing anything.</p>
  <p>Seems to be a timing issue with asynchronous call but im stumped. Any ideas why?</p>
  <pre><code>import React, { Component } from 'react';
  import { getSearchResults} from '../services/searchService';
  import AircraftsTable from '../components/aircraftsTable';
  import Pagination from '../components/common/pagination';
  import qs from 'qs';
  
  class SearchResults extends Component {
      state = { 
          aircrafts: [],
          totalCount:0,
          currentPage: 1,
          pageSize: 10
       }
  
       componentDidMount(){
          const { aircrafts, totalCount} = this.getPagedData();
       
          this.setState(aircrafts, totalCount);
      }
  
       handlePageChange = page =&gt; {
          this.setState({ currentPage: page });
        };
  
      getPagedData = async () =&gt; {
          const queryString = this.getQueryString();
          const searchResults = await getSearchResults(queryString);
  
          const aircrafts = searchResults.data.aircrafts;
          const totalCount = searchResults.data.totalCount;
  
          console.log(aircrafts, totalCount);
          
          return [ aircrafts, totalCount ];    
      }
   
      getQueryString(){
          let criteria = this.props.history.location.state?.data;
          criteria.currentPage = this.state.currentPage;
          criteria.pageSize = this.state.pageSize;    
          const criteriaString = qs.stringify(criteria);
  
          return criteriaString;
      }
  
      render() { 
          const { aircrafts, totalCount, pageSize, currentPage} = this.state;
  
          return ( 
              &lt;React.Fragment&gt;
              &lt;AircraftsTable
                  aircrafts={aircrafts}
              /&gt;
              &lt;Pagination
              itemsCount={totalCount}
              pageSize={pageSize}
              currentPage={currentPage}
              onPageChange={this.handlePageChange}
            /&gt;
            &lt;/React.Fragment&gt;
           );
      }
  }
   
  export default SearchResults;
  
  </code></pre>