skip to Main Content

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

Answers


  1. 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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search