-
Notifications
You must be signed in to change notification settings - Fork 6
/
state.html
50 lines (40 loc) · 1.4 KB
/
state.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
<title>Basic Example Props</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<script type="text/jsx">
var Avatar = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
width: React.PropTypes.number.isRequired,
height: React.PropTypes.number.isRequired
},
getInitialState() {
return {
src: 'http://canime.files.wordpress.com/2010/05/mask-dtb.jpg'
};
},
onClick() {
this.setState({src: 'http://38.media.tumblr.com/9f96b52d8fda03c77d0b620d4f12a128/tumblr_n0lvu7fSqE1sont7fo1_500.gif'});
},
render() {
//var src='http://canime.files.wordpress.com/2010/05/mask-dtb.jpg';
return (
<div>
<img src={this.state.src} width={this.props.width} height={this.props.height} alt="alt" />
<span>{this.props.name}</span>
<button onClick={this.onClick}>So HOT!!!!</button>
</div>
);
}
});
var AvatarEl = <Avatar name="Foo" width={100} height={100}/>;
var AvatarComponent = React.render(AvatarEl, document.body);
</script>
</body>
</html>