In React I have stored images in different variables like
import Small from '../images/small.png'
import Medium from '../images/medium.png'
And I store these variables in a data.js file like
const Paper = [{ Head: "<strong>Heading Content</strong>sub-heading", content: ["Small","Medium"] },{ Head: "<strong>Heading Content 2</strong>sub-heading", content: ["Small","Medium"] }...];
Then print this datas in my page Heading
are print okay but the the images not showing:
{Head}
{Paper.map((Paper,index) => (
<div className='news-papper'>
<img className='images' src={images[index]} alt='ans-img'/>
</div>
))
}
how to print the image from JSON data in react, I am new in react.
images[index]
and you are saying there is no image shown. What isimages
and how you fill it? – Doc["Small","Medium"]
doesn't store the images. They're only strings in an array. – evolutionxbox