title: React this.state undefined array
body: <p>I have an issue with React.
  I have an array that I pass to this.state. But I'm facing an issue, I can't access to the sub-elements in the array. In my case, I can't access to this.state.folders[0].</p>
  
  <p>Here is my code :</p>
  
  <pre><code>class DriveContent extends Component {
      constructor () {
          super();
          let list_files = [];
          let list_folders = [];
          axios.get('/api/getFilesAndFolders').then((response) =&gt; {
              for (var i = 0; i &lt; response.data.length; i++) {
                if (response.data[i]["isFile"] ==true){
                    list_files.push(response.data[i]);
                }
                else {
                    list_folders.push(response.data[i]);
                }
              }
          }).catch((error) =&gt; {
               console.error(error);
          });
  
         this.state = {files: list_files, folders: list_folders};
         console.log(this.state.folders);
         console.log(this.state.folders[0]);
      }
  </code></pre>
  
  <p>Here is what return the the 2 console.log :</p>
  
  <pre><code>// console.log(this.state.folders);
          []
      0: "Commun"
      1: "Privé"
      2: "Public"
      length: 3
  
  //console.log(this.state.folders[0]);
      undefined
  </code></pre>
  
  <p>Thanks in advance !</p>