Skip to content

Instantly share code, notes, and snippets.

@kazagkazag
Created July 7, 2016 10:06
Show Gist options
  • Save kazagkazag/7c16a1efc41d400836262b294afa3188 to your computer and use it in GitHub Desktop.
Save kazagkazag/7c16a1efc41d400836262b294afa3188 to your computer and use it in GitHub Desktop.
// MyComponent.jsx
export class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {counter: 0};
this.onButtonClick = this.onButtonClick.bind(this);
}
render() {
return (
<div className="my-div">
My div content
<MyButton onButtonClick={this.onButtonClick} buttonTitle={"Clicked times: " + this.state.counter} />
</div>
);
}
onButtonClick() {
this.setState({
counter: this.state.counter + 1
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment