Skip to content

Instantly share code, notes, and snippets.

@dceddia
Created November 17, 2017 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dceddia/e43eb4d4192cc59447d3783a00040b31 to your computer and use it in GitHub Desktop.
Save dceddia/e43eb4d4192cc59447d3783a00040b31 to your computer and use it in GitHub Desktop.
import React from 'react';
class Counter extends React.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>
)
}
}
export default Counter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment