How to give Image src dynamically in react js? : <p>I am trying to give image name in src dynamically. I want to set image name dynamically using variable with path. but I am not able to set src correctly. I tried solutions on stackoverflow but nothing is working. </p>

<p>I tried to give path like this </p>

<pre><code>&lt;img src={`../img/${img.code}.jpg`}&gt;&lt;/img&gt;

&lt;img src={'../img/' + img.code + '.jpg'}&gt;&lt;/img&gt;

&lt;img src={'../img/{img.code}.jpg'}&gt;&lt;/img&gt;
</code></pre>

<p>my images are saved in src/img path
if i give path like this</p>

<pre><code>&lt;img src={require('../img/nokia.jpg')}/&gt;
</code></pre>

<p>image is showing </p>

<p>I know this question is asked before but nothing is working for me.
Please help me how can I set image path?</p>
