class Test extends React.Component {
constructor(props) {
super(props)
this.state = {
count: 1
}
}
handler = () => {
this.setState({
count: ++this.state.count
})
}
render() {
return (
<div>
<button onClick={this.handler}>Add 1</button>
<p>{this.state.count}</p>
</div>
);
}
}
ReactDOM.render(
<Test />,
document.getElementById("test"));