Last active
August 29, 2015 14:19
-
-
Save AlecAivazis/0ee25aa63fb3ed8a4332 to your computer and use it in GitHub Desktop.
ES6 React Component
This file contains 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'; | |
// the base application component for syllabus | |
class Test extends React.Component{ | |
constructor(){ | |
// create this | |
super(); | |
// set the initial state | |
this.state = { | |
count: 0 | |
}; | |
// bind the class functions to the instance of the element | |
this.increment = this.increment.bind(this); | |
} | |
increment() { | |
this.setState({ | |
count: this.state.count + 1 | |
}); | |
} | |
render() { | |
return ( | |
<div onClick={this.increment}> | |
count: {this.state.count} | |
</div> | |
) | |
} | |
} | |
React.render(<Test/>, document.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment