Last active
April 13, 2017 02:12
-
-
Save osanyin/98b1fa6eb4199e88cdb3cc6c80b75820 to your computer and use it in GitHub Desktop.
React: Anatomia de um componente
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
| class Counter extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = {count: 0}; | |
| } | |
| incrementCount() { | |
| this.setState({ | |
| count: this.state.count + 1 | |
| }); | |
| } | |
| render() { | |
| return ( | |
| <div> | |
| counter: {this.state.count} | |
| <button type="button" onClick={this.incrementCount.bind(this)}>Increment</button> | |
| </div> | |
| ); | |
| } | |
| }; | |
| ReactDOM.render( | |
| <Counter />, | |
| document.body | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment