Guest User

Untitled

a guest
Apr 22nd, 2019
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react'
  2.  
  3. export default class Count extends Component {
  4. state = {
  5. count: 0
  6. }
  7.  
  8. clickHandler(value) {
  9. this.setState({
  10. count: value
  11. });
  12. }
  13.  
  14. render() {
  15. return (
  16. <div>
  17. <div>
  18. <button onClick={() => this.clickHandler(this.state.count + 1)}> + Increment</button>
  19. <button onClick={() => this.clickHandler(this.state.count - 1)}> - Decrement</button>
  20. </div>
  21. <div>
  22. Current: {this.state.count}
  23. </div>
  24. </div>
  25. )
  26. }
  27. }
RAW Paste Data