Skip to content

Instantly share code, notes, and snippets.

@ManasJayanth
Last active July 8, 2018 18:45
Show Gist options
  • Save ManasJayanth/7a0e6f9a132954b443627d9e7f47306d to your computer and use it in GitHub Desktop.
Save ManasJayanth/7a0e6f9a132954b443627d9e7f47306d to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
class App extends Component {
constructor() {
super();
this.state = {
count: 0
};
}
render() {
const onClickHandler = () => {
this.setState(state => {
return {
count: state.count + 1
};
});
};
return (
<div className="root">
{ /* Add <p><span>some text</span></p> temporarily and see prepareUpdate and commitUpdate get called 5 times instead of 3 */ }
<div className="counter">{this.state.count}</div>
<button onClick={onClickHandler}>Increment</button>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment