'Not able to load image using img element in ReactJS
Image Source I want to load: http://openweathermap.org/img/wn/[email protected]
Code used:
<img
src={
'http://openweathermap.org/img/wn/' +
{this.state.weatherdata.weather[0].icon} +
'@2x.png'
}
></img>
Solution 1:[1]
Did you try the following?
console.log('http://openweathermap.org/img/wn/'+{this.state.weatherdata.weather[0].icon}+'@2x.png'})
Try to console it since I dont know the details of this I cant help you, there should be a problem with your string
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Prashant G |