-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
62 lines (49 loc) · 1.86 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
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src ="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0-alpha1/JSXTransformer.js"></script>
<title>My First React</title>
</head>
<body>
<div id="mount-point"></div>
<script type="text/jsx">
// custom components
var MyComponent = React.createClass({
incrementCount: function(){
// setting the state of the component
this.setState({
count: this.state.count + 1
});
},
displayCreatorName: function(){
this.setState({
name: "Navindren"
})
},
// the intial state of the component
getInitialState: function(){
return {
count: 12
}
},
render: function(){
return (
// render the component's html to the mounting point
<div class="my-component">
<h1>Name: {this.state.name}</h1>
<h1>Count: {this.state.count}</h1>
<button type="button" onClick={this.incrementCount}>Increment</button>
<br/>
<button type="button" onClick={this.displayCreatorName}>Creator Name</button>
</div>
);
}
});
// render my custom component
ReactDOM.render(<MyComponent name= "Navindren" />,document.getElementById('mount-point'));
</script>
</body>
</html>