What I'm trying to do is removal of duplicate codes like below.
import icon1 from './images/abc.png'
import icon2 from './images/xyz.png'
import icon3 from './images/pqr.png'
import icon4 from './images/stu.png'
...
<img src={icon1}/>
<img src={icon2}/>
<img src={icon3}/>
<img src={icon4}/>
...
I want to rewrite above code using loop or map function like below conceptually.
let array = [1,2,3,4];
{array.map( v =>
<img src={icon + v} />
);}
Sure, it does not work. In using React.js, how can I make use of variable using string concatenation?