title: Rendering react component after api response
body: <p>I have a react component that I wish to populate with images using the Dropbox api. The api part works fine, but the component is rendered before the data comes through &amp; so the array is empty. How can I delay the rendering of the component until it has the data it needs?</p>
  
  <pre><code>var fileList = [];
  var images = [];
  var imageSource = [];
  
  class Foo extends React.Component {
  
   render(){
    dbx.filesListFolder({path: ''})
    .then(function(response) {
     fileList=response.entries;
     for(var i=0; i&lt;fileList.length; i++){
      imageSource.push(fileList[0].path_lower);
     }
     console.log(imageSource);
     })
  
    for(var a=0; a&lt;imageSource.length; a++){
     images.push(&lt;img key={a} className='images'/&gt;);
    }
  
    return (
     &lt;div className="folioWrapper"&gt;
      {images}
     &lt;/div&gt;
    );
   }
  }
  </code></pre>
  
  <p>Thanks for your help!</p>