Skip to content

Commit 414fec8

Browse files
author
Matt Calthrop
committed
Add tutorial6-7
1 parent 588f6a4 commit 414fec8

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

public/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<!--<script type="text/babel" src="scripts/example.js"></script>-->
1717
<!--<script type="text/babel" src="scripts/tutorial1.js"></script>-->
1818
<!--<script type="text/babel" src="scripts/tutorial2-3.js"></script>-->
19-
<script type="text/babel" src="scripts/tutorial4-5.js"></script>
19+
<!--<script type="text/babel" src="scripts/tutorial4-5.js"></script>-->
20+
<script type="text/babel" src="scripts/tutorial6-7.js"></script>
2021
</body>
2122
</html>

public/scripts/tutorial6-7.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* global React, ReactDOM */
2+
3+
var Comment = React.createClass({
4+
rawMarkup: function () {
5+
var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
6+
7+
return {__html: rawMarkup};
8+
},
9+
render: function () {
10+
return (
11+
<div className="comment">
12+
<h2 className="commentAuthor">
13+
{this.props.author}
14+
</h2>
15+
<span dangerouslySetInnerHTML={this.rawMarkup()}/>
16+
</div>
17+
);
18+
}
19+
});
20+
21+
var CommentList = React.createClass({
22+
render: function () {
23+
return (
24+
<div className="commentList">
25+
<Comment author="Pete Hunt">This is one comment</Comment>
26+
<Comment author="Jordan Walke">This is *another* comment</Comment>
27+
</div>
28+
);
29+
}
30+
});
31+
32+
var CommentForm = React.createClass({
33+
render: function () {
34+
return (
35+
<div className="commentForm">
36+
Hello, world! I am a CommentForm.
37+
</div>
38+
);
39+
}
40+
});
41+
42+
var CommentBox = React.createClass({
43+
render: function () {
44+
return (
45+
<div className="commentBox">
46+
<h1>Comments</h1>
47+
<CommentList />
48+
<CommentForm />
49+
</div>
50+
);
51+
}
52+
});
53+
54+
ReactDOM.render(
55+
<CommentBox />,
56+
document.getElementById('content')
57+
);

0 commit comments

Comments
 (0)