I have the following component in react that dinamically loads an image:
<img src {require(getImgPath()).default}/>
This component throws the following error: Cannot find module './images/abc.svg'
If I change the component to the following:
<img src {require(`${getImgPath()}`).default}/>
Then it works. Why is that?
I also tried this without success:
<img src {require(getImgPath().toString()).default}/>