title: require function not working with image in react
body: <p>I've used <code>&lt;img src={require('./somRelativePath/image.jpg)}</code> in React many times. However, this time it seems not to be working. There are no errors whatsoever (such as that the image was not found etc.) but the broken image on website.</p>
  <p>After inspecting the element I was somewhat confused by the transpiled result in browser:</p>
  <pre><code>&lt;img src=&quot;[object Module]&quot; style=&quot;width: 5rem;&quot;&gt;
  </code></pre>
  <p>It appears as if it loads the image as a component not the acutual file. I've created the app with <code>npx create-react-app</code> and haven't ejected it so far. So there is no error in babel or webpack configuration as it is currently handled by react under the hood.</p>
  <p>Importing it with <code>import</code> statement works just fine:</p>
  <pre><code>import calendarPic from '../assets/pictures/calendar.svg';
  </code></pre>
  <p>Unfortunately that's not the solution because I have the local images saved in json and it would be definitely quite repetitive and ineffective as well to load all 50 images.</p>
  <p>With the same <code>npx create-react-app</code> I've made a handful of mini-projects before but have never come across such a perplexing, yet so basic error. I'd be so thankful for any response as I've skimmed every possible solution throughout the internet.</p>
  <p>Thank you again and have a lovely day!</p>