// 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
});
}
}