I have a javascript array of image sources. Now I need to implement each of the image source in individual box background. I am trying to put the array element into React JSX style element like below (demo code)
const box = []
for(const [index, image] of images.entries()) {
box.push(
<Box key={index} style={{background: 'url(image)'}}>
Some code goes here.......
</Box>
)}
return(<div>{box}</div>)
Hope I can make you understand my problem. Please help, any alternative way is always welcome. thank you in advance
const imageBoxes = images.map((image, index) => <JSX />). You can then render<div>{imageBoxes}</div>into your main render, or do the.mapdirectly in there.