So what I an trying to do is to read image-src from a JSON file. In the JSON file I have something like this:
{
posts:[
{"img": "../images/a.png"},
{"img": "../images/b.png"},
//and more...
]
}
Then I am trying to use these paths as image src in react:
import data from '../posts.json';
<img src={require(data.posts[0].img)}/>
This does not work, I get this error: Error: Cannot find module ".". Is there a way I can make this work?