comments list shows comments

master
Matt Huntington 9 years ago
parent 8e29472bd2
commit 16db114112

@ -3,9 +3,25 @@ import CommentsList from './CommentsList.js';
import CommentsForm from './CommentsForm.js';
class App extends React.Component {
constructor(props){
super(props);
this.state = {
comments: [
{
body:'eat'
},
{
body:'sleep'
},
{
body:'find shelter'
}
]
}
}
render() {
return <section>
<CommentsList/>
<CommentsList comments={this.state.comments}/>
<CommentsForm/>
</section>
}

@ -3,7 +3,9 @@ import React from 'react';
class CommentsList extends React.Component {
render() {
return <ul>
<li>comments list</li>
{this.props.comments.map((comment, index) =>
<li key={index}>{comment.body}</li>
)}
</ul>
}
}

Loading…
Cancel
Save