I am new to REACT and want to do a challenge with (different) stories thats displays the stories in different cards.
So I tried to create a card component that displays title, description and difficulty. I added an object named stories
class Card extends React.Component {
render() {
const stories = [
{
id: 1,
title: 'First black story',
desc: 'Can you solve this hard puzzle?',
grade: 'Hard'
},
{
id: 2,
title: 'Second black story',
desc: 'This should be easy for you!',
grade: 'Makkelijk'
}
];
I tried mapping through to object and adding all the details do elements like <h2>, <p> with map function:
return({stories,map((story, index) => {
return (
<div key={index}>
<h2>name: {story.title}</h2>
<h2>country: {story.desc}</h2>
<hr />
</div>
);
})});
}
}
export default Card;
and tried to call the cards in my Home.js with
<div id="cardsOverview">
<Card />
<Card />
<Card />
</div>
But without success, what am I doing wrong?
I personally think the <Card /> is not going to work that easily because REACT doesn't know what card it should load, but I want it to load every card, so why should it matter WHAT card.