Here is my path to the image: ../src/assets/images/img_name.jpg"
And path to the file.js: src/file_name.js
If I implement my code in file.js like this:
- Import img_name from
"../src/assets/images/img_name.jpg"
- Then reference the img path in href tag:
<img src={img_name}></img>
It will work but If I dont import and reference the img like this: <img src='../src/assets/images/img_name.jpg'></img>
It won't work no more. Can anyone explain why??
I use create-react-app
CodePudding user response:
I think my problem is here:
React won't load local images
or if anyone knows how to explain it clearer please let us know your answer
CodePudding user response:
you have to explictly import image file since webpack need proper loader for this file