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

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

Loading…
Cancel
Save