0

I'm following a React.JS tutorial and I'm having problems displaying an image. I don't get any errors but the image is not displaying. Below is the component and import code. Thank you.

------- Data.js-->

export const homeObjOne = { id: "about", ... imgStart: false, img: require("../../../images/svg-1.svg"), alt: "Car", ... }; 

------- Index.js-->

import { ..... Img, } from "./InfoElements"; const InfoSection = ({ ... img, ImgWrap ... }) => { return ( <> ... <ImgWrap> <Img src={img} alt={alt} /> </ImgWrap> ... </> ); }; export default InfoSection; 

1 Answer 1

1

Need add .default after require(""). like require("").default

export const homeObjOne = { id: "about", ... imgStart: false, img: require("../../../images/svg-1.svg").default, alt: "Car", ... }; 
Sign up to request clarification or add additional context in comments.

1 Comment

Awsome it worked! Thank you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.