Home > Blockchain >  How to import a folder/file from public folder to src folder in react
How to import a folder/file from public folder to src folder in react

Time:12-24

Trying to import image folder from public folder to src folder in react but i kept getting error messages in the terminal and my chrome

[the vscode screenshot](https://i.stack.imgur.com/gtyL0.png)

CodePudding user response:

you need to import from the folder in which the file exists

import Airbnb from '../../public/Images/airbnb.png'

CodePudding user response:

Your image is inside a Image folder. So the import should be

import Airbnb from '/Images/airbnb.png'

If it gives webpack import error you can do it like this way

<img src='/Images/airbnb.png'/>

Here /Images/airbnb.png gives a direct link to the image of the public folder.

  • Related