Skip to content

Instantly share code, notes, and snippets.

@michaelkutuzov
Created September 14, 2020 11:01
Show Gist options
  • Select an option

  • Save michaelkutuzov/8f83aefc3c1fe5e6adef10b3b995acce to your computer and use it in GitHub Desktop.

Select an option

Save michaelkutuzov/8f83aefc3c1fe5e6adef10b3b995acce to your computer and use it in GitHub Desktop.
Fiber inside 1
class ClickCounter extends React.Component {
constructor(props) {
super(props);
this.state = {count: 0};
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState((state) => {
return {count: state.count + 1};
});
}
render() {
return [
<button key="1" onClick={this.handleClick}>Update counter</button>,
<span key="2">{this.state.count}</span>
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment