-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
59 lines (55 loc) · 1.48 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="http://fb.me/react-0.12.2.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.2.js"></script>
<script type="text/jsx">
var TextInput = React.createClass({
propTypes: {
value: React.PropTypes.string,
onChange: React.PropTypes.func
},
render: function(){
return <input type="text" value={this.props.value} onChange={this.props.onChange} />
}
});
var Me = React.createClass({
getDefaultProps:function(){
return {
name: 'benjamin'
}
},
propTypes: {
name: React.PropTypes.string
},
render: function(){
var name = this.props.name;
return <span>{name}</span>
}
});
var App = React.createClass({
getInitialState:function() {
return {
name: 'Benjamin'
}
},
updateName: function(e){
this.setState({name: e.target.value})
},
render: function(){
return (
<div>
<TextInput value={this.state.name} onChange={this.updateName} />
<h1>Hello <Me name={this.state.name} /></h1>
</div>
)
}
});
React.render(<App />, document.body);
</script>
</body>
</html>