click conter example
Alex Smith committed
Jun 26, 2015 at 13:08 UTC
e766d5539e3b5e58aab92b919bf18cd35aec3ca5
1 file changed
+31
examples/click-counter/Index.html
new
+31
@@ -0,0 +1,31 @@
1
+<!DOCTYPE html>
2
+<html>
3
+ <head>
4
+ <title>React click conter example</title>
5
+ <script src="https://fb.me/react-with-addons-0.13.3.js"></script>
6
+ <script type="text/javascript">
7
+ var Counter = React.createClass({
8
+ getInitialState: function() {
9
+ return { clickCount: 0 };
10
+ },
11
+ handleClick: function() {
12
+ var selfClickNumber = this.state.clickCount;
13
+ this.setState({clickCount: ++selfClickNumber});
14
+ },
15
+ render: function () {
16
+ return React.DOM.h2({onClick: this.handleClick}, 'Count number: '+this.state.clickCount);
17
+ }
18
+ });
19
+ </script>
20
+ </head>
21
+ <body>
22
+ <div id="message" align="center"></div>
23
+
24
+ <script type="text/javascript">
25
+ React.render(
26
+ React.createElement(Counter),
27
+ document.getElementById('message')
28
+ );
29
+ </script>
30
+ </body>
31
+</html>
\ No newline at end of file