Skip to content

Instantly share code, notes, and snippets.

@luishdez
Last active September 30, 2015 01:51
Show Gist options
  • Save luishdez/f30214b152fbcf00ff43 to your computer and use it in GitHub Desktop.
Save luishdez/f30214b152fbcf00ff43 to your computer and use it in GitHub Desktop.
counter.jsx
"use strict";
var Counter = React.createClass({
displayName: "Counter",
incrementCount: function incrementCount() {
this.setState({count: this.state.count + 1});
},
getInitialState: function getInitialState() {
return {
count: 0
};
},
render: function render() {
return React.createElement( "div", {
"class": "my-component" },
React.createElement("h1", null, "Count: ", this.state.count),
React.createElement("button", { type: "button", onClick: this.incrementCount }, "Increment"
));
}
});
React.render(React.createElement(Counter, null), document.getElementById('mount-point'));
var Counter = React.createClass({
incrementCount: function(){
this.setState({
count: this.state.count + 1
});
},
getInitialState: function(){
return {
count: 0
}
},
render: function(){
return (
<div class="my-component">
<h1>Count: {this.state.count}</h1>
<button type="button" onClick={this.incrementCount}>Increment</button>
</div>
);
}
});
React.render(<Counter/>, document.getElementById('mount-point'));
<div id="mount-point"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment