Created
December 3, 2017 15:53
-
-
Save MicroBenz/a5e99e1e6c02cb95ac41dc6d23e5f753 to your computer and use it in GitHub Desktop.
Recompose
This file contains 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 { | |
constructor(props) { | |
super(props); | |
this.state = { counter: 0 }; | |
this.handleCount = this.handleCount.bind(this); | |
} | |
handleCount(count) { | |
this.setState({ counter: this.state.counter + count }); | |
} | |
render() { | |
const { counter } = this.state; | |
return ( | |
<div> | |
Count: {counter} | |
<button onClick={() => this.handleCount(1)}>Increase</button> | |
<button onClick={() => this.handleCount(-1)}>Decrease</button> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment