1

This is my App.js. Here, I call the "Profile" Component.

import './App.css'; import Profile from "./Profile" function App() { return ( <div className="App"> <Profile /> </div> ); } export default App; 

Then, inside Profile.js, I call Card component and inside the Card component, I've enclosed an image.

import React from 'react' import Card from './Card' import styles from "./Profile.module.css" import image1 from "./assets/profile1.png" const Profile = () => { return ( <Card> <div> <img src={image1} alt="" /> </div> </Card> ) } export default Profile 

Inside of Card component, I've just applied some CSS to make it look like a Card.

import React from 'react' import styles from "./Card.module.css" const Card = () => { return ( <div className={styles.card}> </div> ) }export default Card 

This is my folder structure.

enter image description here

I'm really confused why the image isn't getting showed up. Currently this is the output I'm getting.

enter image description here

I've restarted the server as well. But it's not getting fixed.

1
  • In your browser, open the devtools and check the network panel to see the request that's going out. Seems like you might have an incorrect path structure; you'll be able to see it easily from the devtools where it is trying to load the image from. Commented Jan 3, 2023 at 16:54

1 Answer 1

1

your card doesn't have a child component return maybe that could be the problem

 import React from 'react' import styles from "./Card.module.css" const Card = ({children}) => { return ( <div className={styles.card}> {children} </div> ) } export default Card 

try this

Sign up to request clarification or add additional context in comments.

2 Comments

Why does it fix the issue(It did indeed)?
when you pass something wrapping your custom component it will take that tag as a children's tag.. you have to specify that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.