Last active
September 30, 2015 01:51
-
-
Save luishdez/f30214b152fbcf00ff43 to your computer and use it in GitHub Desktop.
counter.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="mount-point"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment