Last active
December 3, 2017 22:02
-
-
Save rafaellucio/5c815de0e44f9cbd6c604f36f34cbd6b 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' | |
| export default class Counter extends Component { | |
| state = { | |
| count: 0 | |
| } | |
| increment = () => { | |
| this.setState({ | |
| count: this.state.count + 1 | |
| }) | |
| } | |
| decrement = () => { | |
| this.setState({ | |
| count: this.state.count - 1 | |
| }) | |
| } | |
| render() { | |
| return ( | |
| <div> | |
| <h2>Counter</h2> | |
| <div> | |
| <button onClick={this.decrement}>-</button> | |
| <span>{this.state.count}</span> | |
| <button onClick={this.increment}>+</button> | |
| </div> | |
| </div> | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment