src={require(`../../assets/Resume/${bullet.logoSrc}`).default}

Viewed 24

I'm unable to import image in react using default Rule in react Js

  <img
          className="bullet-logo"
          src={require(`../../assets/Resume/${bullet.logoSrc}`).default}
          alt="B"
        />
1 Answers

The problem is, you can't dynamically build your require paths. If you want to use multiple images in a react application you can create a file, create all paths there and then import the file into the component, where you need the information. The file should look somewhat like:

export const images = { image1: require("../path"), image2: require("../path")}

Then just import the images object into another file.

Related