I am trying to pass an image from an array of JS objects which contain images and some other basic values. However, for some reason, I am unable to pass the images but everything else is working fine can someone please help take a look please thanks so much.
import './index.css'
import Navbar from './Navbar'
import Hero from './Hero'
import Card from './Card'
import carddata from './data'
const data = carddata.map((info)=>{
return(
<Card
key={info.key}
img={info.coverImg}
rating={info.stats.rating}
reviewCount={info.stats.reviewCount}
location={info.location}
title={info.title}
price={info.price}
/>
)
})
export default function App() {
return (
<div>
<Navbar/>
<Hero/>
<section className='cards-list'>
{data}
</section>
</div>
)
}
import stars from '/assets/images/Star1.png'
import PropTypes from 'prop-types';
export default function Card(props) {
const {coverImg,reviewCount,location,title,price} = props;
console.log(coverImg);
return(
<div className='card'>
<img src={(`/images${coverImg}`)} alt="swimmerimg" className='card--image' />
<div className='card--stats'>
<img src={stars} alt="stars" className='card--star'/>
<span className='gray'>({reviewCount}) • </span>
<span className='gray'>{location}</span>
</div>
<p className='card--title'>{title}</p>
<p className='card--price'><span className='bold'>From ${price} / person</span></p>
</div>
)
}
Card.propTypes = {
coverImg: PropTypes.string.isRequired,
reviewCount: PropTypes.number.isRequired,
location: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
price: PropTypes.number.isRequired
};
import swimmer from '/assets/images/katie-zaferes.png';
import wedding from '/assets/images/wedding-photography.png';
import bike from '/assets/images/mountain-bike.png';
export default [
{
id: 1,
title: "Life Lessons with Katie Zaferes",
description: "I will share with you what I call \"Positively Impactful Moments of Disappointment.\" Throughout my career, many of my highest moments only came after setbacks and losses. But learning from those difficult moments is what gave me the ability to rise above them and reach my goals.",
price: 136,
coverImg: {swimmer},
stats: {
rating: 5.0,
reviewCount: 6
},
location: "Online",
openSpots: 0,
},
{
id: 2,
title: "Learn Wedding Photography",
description: "Interested in becoming a wedding photographer? For beginner and experienced photographers alike, join us in learning techniques required to leave the happy couple with memories that'll last a lifetime.",
price: 125,
coverImg: {wedding},
stats: {
rating: 5.0,
reviewCount: 30
},
location: "Online",
openSpots: 27,
},
{
id: 3,
title: "Group Mountain Biking",
description: "Experience the beautiful Norwegian landscape and meet new friends all while conquering rugged terrain on your mountain bike. (Bike provided!)",
price: 50,
coverImg: {bike},
stats: {
rating: 4.8,
reviewCount: 2
},
location: "Norway",
openSpots: 3,
}
]