Guest User

Untitled

a guest
Nov 15th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class ClickCounter extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {count: 0};
  5.  
  6. this.onClick = () => {
  7. this.setState((state, props) => {
  8. return {count: state.count + 1};
  9. });
  10. }
  11. }
  12.  
  13. render() {
  14. return [
  15. <button key="1" onClick={this.onClick}>Update name</button>,
  16. <span key="2">{this.state.count}</span>
  17. ]
  18. }
  19.  
  20. componentDidUpdate() {}
  21. getSnapshotBeforeUpdate() { return null }
  22. }
Add Comment
Please, Sign In to add comment