File tree Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < title > data flow - reactjs</ title >
6
+ </ head >
7
+ < body >
8
+ < div id ="data-flow ">
9
+ <!-- hasil reactjs akan di tampilkan disini -->
10
+ </ div >
11
+
12
+ < script src ="../build/react.js "> </ script >
13
+ < script src ="../build/react-dom.js "> </ script >
14
+ < script src ="../browser.min.js "> </ script >
15
+ < script type ="text/babel ">
16
+ var DataFlow = React . createClass ( {
17
+ filterList : function ( event ) {
18
+ var updatedList = this . state . initialItems ;
19
+ updatedList = updatedList . filter ( function ( item ) {
20
+ return item . toLowerCase ( ) . search (
21
+ event . target . value . toLowerCase ( )
22
+ ) !== - 1 ;
23
+ } ) ;
24
+ this . setState ( { items : updatedList } ) ;
25
+ } ,
26
+
27
+ getInitialState : function ( ) {
28
+ return {
29
+ initialItems : [
30
+ "Apples" ,
31
+ "Broccoli" ,
32
+ "Chicken" ,
33
+ "Duck" ,
34
+ "Eggs" ,
35
+ "Fish" ,
36
+ "Granola" ,
37
+ "Hash Browns"
38
+ ] ,
39
+ items : [ ]
40
+ }
41
+ } ,
42
+
43
+ componentWillMount : function ( ) {
44
+ this . setState ( { items : this . state . initialItems } )
45
+ } ,
46
+
47
+ render : function ( ) {
48
+ return (
49
+ < div class = "list-component" >
50
+ < input type = "text" placeholder = "Search" onChange = { this . filterList } />
51
+ < List items = { this . state . items } />
52
+ </ div >
53
+ )
54
+ }
55
+ } ) ;
56
+
57
+ var List = React . createClass ( {
58
+ render : function ( ) {
59
+ return (
60
+ < ul >
61
+ {
62
+ this . props . items . map ( function ( item ) {
63
+ return < li key = { item } > { item } </ li >
64
+ } )
65
+ }
66
+ </ ul >
67
+ ) ;
68
+ }
69
+ } ) ;
70
+
71
+ ReactDOM . render (
72
+ < DataFlow /> ,
73
+ document . getElementById ( 'data-flow' )
74
+ ) ;
75
+ </ script >
76
+ </ body >
77
+ </ html >
You can’t perform that action at this time.
0 commit comments