Skip to content

Instantly share code, notes, and snippets.

@kkga
Created January 1, 2015 14:01
Show Gist options
  • Save kkga/cd5bbac2c88e9a7fc216 to your computer and use it in GitHub Desktop.
Save kkga/cd5bbac2c88e9a7fc216 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://fb.me/react-0.12.0.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var HelloWorld = React.createClass({displayName: 'HelloWorld',
getInitialState: function() {
return {
counter: 0
};
},
increment: function() {
this.setState({ counter: this.state.counter++ });
},
render: function() {
return React.createElement("div", null,
React.createElement("div", null, this.state.counter),
React.createElement("button", {onClick: this.increment}, "Increment!")
);
}
});
React.render(new HelloWorld(), document.body);
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="//fb.me/react-0.12.0.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">var HelloWorld = React.createClass({
getInitialState: function() {
return {
counter: 0
};
},
increment: function() {
this.setState({ counter: this.state.counter++ });
},
render: function() {
return <div>
<div>{this.state.counter}</div>
<button onClick={this.increment}>Increment!</button>
</div>;
}
});
React.render(new HelloWorld(), document.body);</script></body>
</html>
var HelloWorld = React.createClass({displayName: 'HelloWorld',
getInitialState: function() {
return {
counter: 0
};
},
increment: function() {
this.setState({ counter: this.state.counter++ });
},
render: function() {
return React.createElement("div", null,
React.createElement("div", null, this.state.counter),
React.createElement("button", {onClick: this.increment}, "Increment!")
);
}
});
React.render(new HelloWorld(), document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment