Created
July 7, 2016 10:06
-
-
Save kazagkazag/7c16a1efc41d400836262b294afa3188 to your computer and use it in GitHub Desktop.
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
// 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