when i run the project the images in the project aren’t visible in the browser,is there any solution for visible of images in the browser!
project is running smooth but the images aren’t visible.
where my
my mproject link
https://vscode.dev/github/darkleas/company-website-reactjs/blob/main
please show me an where was an retify it.!!!
please help me,i had tried different approaches but i had getting same.
2
Answers
The React bundler requires you to import static files using the
import
keyword (which returns a string) before using them, to ensure they refer to the same file in the build folder.Create react app documentation: https://create-react-app.dev/docs/adding-images-fonts-and-files/
Eg:
As per your folder structure, It seems like you have stored images in the public directory. In order to access those images, you have to enter the path as
/img/img1.png
which refers to the path relative to the public folder.If you have images somewhere in the
src
folder, you can follow the approach mentioned by Shakya above.