React
HTML
<div id="app"></div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
React
class Counter extends React.Component {
constructor() {
super()
this.setCount = this.setCount.bind(this)
this.state = {
count: 5
}
}
incrementCount() {
this.setState((prevState, props) => {
return {
count: prevState.count + 1
}
});
}
componentDidUpdate() {
console.log('update')
}
render() {
return (
<div>
hello { this.state.count }
<button onClick={this.incrementCount}>click</button>
</div>
)
}
}
ReactDOM.render(
<Counter />,
document.getElementById('app')
);