-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (56 loc) · 1.79 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Introduccion React</title>
<link rel="stylesheet" href="styles.css">
<link href="favicon.png" type="image/png" rel="icon" sizes="32x32">
<script src="https://fb.me/react-0.13.3.min.js"></script>
<script src="https://fb.me/JSXTransformer-0.13.3.js"></script>
</head>
<body>
<section id="user">
</section>
<script type="text/jsx">
var User = React.createClass({
getInitialState : function(){
return {
id:1,
username : "@JairAndresDiazPuentes",
avatar : "usuario1.png",
description : "fundacion universitaria los libertadores"
}
},
changeUser : function(id){
if(id==1){
this.setState({
id:2,
username : "@OtroUsuario",
avatar : "usuario2.png",
description : "Otra universidad"
})
}else{
this.setState({
id:1,
username : "@JairAndresDiazPuentes",
avatar : "usuario1.png",
description : "fundacion universitaria los libertadores"
})
}
},
render : function(){
var image = "./images/"+this.state.avatar;
return (
<article className="User" onClick={() => this.changeUser(this.state.id)}>
<img src={image} className="User-avatar" width="100"/>
<div className="User-description">
<p className="User-name">{this.state.username}</p>
<p>{this.state.description}</p>
</div>
</article>
)
}
})
React.render( <User/>, document.getElementById('user'))
</script>
</body>
</html>