1class ClickCounter extends React.Component {
2 constructor(props) {
3 super(props);
4 this.state = { count: 0 };
5 this.handleClick = this.handleClick.bind(this);
6 }
7
8 handleClick() {
9 this.setState(state => {
10 return { count: state.count + 1 };
11 });
12 }
13
14 render() {
15 return [
16 <button key="1" onClick={this.handleClick}>
17 Update counter
18 </button>,
19 <span key="2">{this.state.count}</span>
20 ];
21 }
22}How React Fiber works.
This is a StoryTime rendition of excellent blog post by Max Koretskyi.
Click play or go step by step using the icons on top right.