File tree Expand file tree Collapse file tree 2 files changed +71
-1
lines changed Expand file tree Collapse file tree 2 files changed +71
-1
lines changed Original file line number Diff line number Diff line change 17
17
<!--<script type="text/babel" src="scripts/tutorial1.js"></script>-->
18
18
<!--<script type="text/babel" src="scripts/tutorial2-3.js"></script>-->
19
19
<!--<script type="text/babel" src="scripts/tutorial4-5.js"></script>-->
20
- < script type ="text/babel " src ="scripts/tutorial6-7.js "> </ script >
20
+ <!--<script type="text/babel" src="scripts/tutorial6-7.js"></script>-->
21
+ < script type ="text/babel " src ="scripts/tutorial8-10.js "> </ script >
21
22
</ body >
22
23
</ html >
Original file line number Diff line number Diff line change
1
+ /* global React, ReactDOM */
2
+
3
+ var data = [
4
+ { id : 1 , author : "Neil Peart" , text : "Hemispheres" } ,
5
+ { id : 2 , author : "Neil Fallon" , text : 'Blast Tyrant' }
6
+ ] ;
7
+
8
+ var Comment = React . createClass ( {
9
+ rawMarkup : function ( ) {
10
+ var rawMarkup = marked ( this . props . children . toString ( ) , { sanitize : true } ) ;
11
+
12
+ return { __html : rawMarkup } ;
13
+ } ,
14
+ render : function ( ) {
15
+ return (
16
+ < div className = "comment" >
17
+ < h2 className = "commentAuthor" >
18
+ { this . props . author }
19
+ </ h2 >
20
+ < span dangerouslySetInnerHTML = { this . rawMarkup ( ) } />
21
+ </ div >
22
+ ) ;
23
+ }
24
+ } ) ;
25
+
26
+ var CommentList = React . createClass ( {
27
+ render : function ( ) {
28
+ var commentNodes = this . props . data . map ( function ( comment ) {
29
+ return (
30
+ < Comment key = { comment . id } author = { comment . author } >
31
+ { comment . text }
32
+ </ Comment >
33
+ ) ;
34
+ } ) ;
35
+
36
+ return (
37
+ < div className = "commentList" >
38
+ { commentNodes }
39
+ </ div >
40
+ ) ;
41
+ }
42
+ } ) ;
43
+
44
+ var CommentForm = React . createClass ( {
45
+ render : function ( ) {
46
+ return (
47
+ < div className = "commentForm" >
48
+ Hello, world! I am a CommentForm.
49
+ </ div >
50
+ ) ;
51
+ }
52
+ } ) ;
53
+
54
+ var CommentBox = React . createClass ( {
55
+ render : function ( ) {
56
+ return (
57
+ < div className = "commentBox" >
58
+ < h1 > Comments</ h1 >
59
+ < CommentList data = { this . props . data } />
60
+ < CommentForm />
61
+ </ div >
62
+ ) ;
63
+ }
64
+ } ) ;
65
+
66
+ ReactDOM . render (
67
+ < CommentBox data = { data } /> ,
68
+ document . getElementById ( 'content' )
69
+ ) ;
You can’t perform that action at this time.
0 commit comments