Last active
July 8, 2018 18:45
-
-
Save ManasJayanth/7a0e6f9a132954b443627d9e7f47306d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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