Want to Use images from project/public/images folder to card inside src/pages/home.js

25 Views Asked by At

I want to use images from project/public/images/ to my card inside src/pages/home.js using map function. When I try to use map function it shows error How do I solve this problem

I to made a js file name data js where I give path bur it shows error how can I give path of images inside public/images/ inside data js and use it in home page

2

There are 2 best solutions below

0
Marcel On

I dont know what error you are getting, nor do i fully understand your problem. If you ask how to use images in your jsx:

import logo from "../public/images/logo.png"

const home = () => {

   return (
      <img src={logo} /> 
   )

}

If i misunderstood your problem please supply your code and the error message you are getting

0
X8inez On

To access images from the image directory in your public folder do this:

<img src="/images/image.png" /> 

replace image.png with the filename of the image you want to use.