i have a code where im fetching the image name
const [foundImg, setFoundImg] = useState(false)
var imgNames = []
---
axios.get('http://someapi.com')
.then(res => {
imgNames.push(res.data)
setFoundImg(true)
}.catch(err => console.log(err)
And i put this condition in the return / render
{ (foundImg === true)
? itemImg.map( i => {
return <div className="product--box">
<Image width={50} height={50} src='/public/dummy.png' className='img'/>
</div>
})
: null
}
But the problem is, when the imagenames are fetched, the component doesnt re render. So it is still empty now. How can i make it so that this image are rendered when the fetching returns data?