A
A
antonstolar2019-09-18 17:03:42
React
antonstolar, 2019-09-18 17:03:42

How to display posts from an array on a page?

I'm making a blog site, you just need to display two posts per page. The "like", "comment" and "read more" buttons shouldn't have functionality right now, they're just for visualization at the moment. I will work on their functionality later.
Posts are stored in objects that are in an array.
I tried to do this task but the code doesn't work...
Here is the code:
https://jsfiddle.net/txo4g01y/9/
Please help me to fix the code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vadimMalovaniy, 2019-09-18
@antonstolar

You need to change the id in HTML and the name of the class. Because your names don't match

ReactDOM.render(<App automobile={data} />, document.getElementById('app'));

And wrap the array itself in a div before rendering.
render () {
  const automobile = this.props.automobile;
   return (
   <div>
    {automobile.map(n => (
       <div className="Cars" headerText={n.name}>
       ....
      </div>
    ))}
   </div>
  );
 }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question