SHARE
TWEET

Untitled

a guest Apr 22nd, 2019 61 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top