title: React - Dynamically loading an image
body: <p>I have a JSON response with a load of data such as an image location.</p>
  
  <p>Then when I try to load the image React cannot find it. </p>
  
  <p>None of the answers of similar questions help because they all tell me to import the image but I need to load it on the cuff. Eg:</p>
  
  <pre><code>{Object.values(this.state.advertisements).map((advertisement, i) =&gt; {
  ...
  &lt;img width='80px' src={require(advertisement.image)} alt='house'/&gt;
  </code></pre>
  
  <p>Then I get an error 'cannot find module'.</p>
  
  <p>The path looks like this:</p>
  
  <blockquote>
    <p>image: <code>./images/house.JPG</code>,</p>
  </blockquote>