I want to load an image based on the state which I am getting from API call. For example, if the API gives me '1'
, I want to load 1.png
. Unfortunately I am getting the above error.
Here is my code
let img = info.WeatherIcon ? require(`../../img/icons/${info.WeatherIcon}.png`) : require('../../img/icons/7.png')
< Image style = {{ width:120, height:120}} source = { img } />