tutorial.js 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. let Comment = React.createClass({
  2. render: function () {
  3. return (
  4. <div className="comment">
  5. <h2 className="commentAuthor">
  6. {this.props.author}
  7. </h2>
  8. {marked(this.props.children.toString())}
  9. </div>
  10. );
  11. }
  12. });
  13. let CommentList = React.createClass({
  14. render: function () {
  15. return (
  16. <div className="commentList">
  17. <Comment author="Pete Hunt">This is one comment</Comment>
  18. <Comment author="Jordan Walke">This is *another* comment</Comment>
  19. </div>
  20. );
  21. }
  22. });
  23. let CommentForm = React.createClass({
  24. render: function () {
  25. return (
  26. <div className="commentForm">
  27. Hello, world! I am a CommentForm.
  28. </div>
  29. );
  30. }
  31. });
  32. let CommentBox = React.createClass({
  33. render: function () {
  34. return (
  35. <div className="commentBox">
  36. <h1>Comments</h1>
  37. <CommentList />
  38. <CommentForm />
  39. </div>
  40. );
  41. }
  42. });
  43. ReactDOM.render(
  44. <CommentBox />,
  45. document.getElementById("content")
  46. );