Files
react/examples/basic-click-counter/index.html
2015-07-12 10:54:54 +09:00

34 lines
885 B
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Basic Example with Click Counter</title>
<script src="../../build/react.js"></script>
<script src="../../build/JSXTransformer.js"></script>
<script type="text/jsx">
var Counter = React.createClass({
getInitialState: function () {
return { clickCount: 0 };
},
handleClick: function () {
this.setState(function(state) {
return {clickCount: state.clickCount + 1};
});
},
render: function () {
return (<h2 onClick={this.handleClick}>Click me! Number of clicks: {this.state.clickCount}</h2>);
}
});
</script>
</head>
<body>
<div id="message" align="center"></div>
<script type="text/jsx">
React.render(<Counter />,
document.getElementById('message')
);
</script>
</body>
</html>