Last active
September 25, 2015 14:08
-
-
Save renren89/2fbbf298747af46d68f3 to your computer and use it in GitHub Desktop.
CommentBox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropType } from 'react'; | |
import CommentList from './CommentList'; | |
import CommentForm from './CommentForm'; | |
import comments from './Comments'; | |
export default class App extends Component { | |
render() { | |
return ( | |
<div> | |
<h1>Comments</h1> | |
<CommentList data={comments} /> | |
<CommentForm /> | |
</div> | |
) | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
export default class Comment extends Component { | |
render() { | |
const { author, text } = this.props; | |
return ( | |
<div> | |
<h2>{author}</h2> | |
{text} | |
</div> | |
); | |
} | |
} |
Raw
CommentList.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
import React, { Component, PropTypes } from 'react'; | |
import Comment from './Comment'; | |
export default class CommentList extends Component { | |
render() { | |
const { author, text } = this.props; | |
return ( | |
<div> | |
{this.props.data.map((comments) => { | |
<Comment author={comments.author}>{comments.text}</Comment> | |
})} | |
</div> | |
); | |
} | |
} | |
CommentList.propTypes = { | |
data: PropTypes.array.isRequired, | |
author: PropTypes.string.isRequired, | |
text: PropTypes.string.isRequired | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default [ | |
{author: "Pete Hunt", text: "this is a comment"}, | |
{author: "Jordan Walke", text: "this is another comment"} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment