Skip to content

Instantly share code, notes, and snippets.

@osanyin
Last active April 13, 2017 02:12
Show Gist options
  • Select an option

  • Save osanyin/98b1fa6eb4199e88cdb3cc6c80b75820 to your computer and use it in GitHub Desktop.

Select an option

Save osanyin/98b1fa6eb4199e88cdb3cc6c80b75820 to your computer and use it in GitHub Desktop.
React: Anatomia de um componente
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