Skip to content

Commit ca02766

Browse files
committed
[+] data-flow
1 parent aefd774 commit ca02766

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

data-flow/index.html

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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>

0 commit comments

Comments
 (0)