Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react'
- export default class Count extends Component {
- state = {
- count: 0
- }
- clickHandler(value) {
- this.setState({
- count: value
- });
- }
- render() {
- return (
- <div>
- <div>
- <button onClick={() => this.clickHandler(this.state.count + 1)}> + Increment</button>
- <button onClick={() => this.clickHandler(this.state.count - 1)}> - Decrement</button>
- </div>
- <div>
- Current: {this.state.count}
- </div>
- </div>
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement