Skip to content

Instantly share code, notes, and snippets.

@jsalonen
Last active February 6, 2019 15:08
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 jsalonen/2f8496c9ded478062f4882567cdf8632 to your computer and use it in GitHub Desktop.
Save jsalonen/2f8496c9ded478062f4882567cdf8632 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
class Counter extends Component {
constructor(props) {
super(props);
this.state = {
count: 0
};
}
setCount(count) {
this.setState({ count });
}
render() {
return (
<div>
<p>You clicked {this.state.count} times</p>
<button onClick={() => this.setCount(this.state.count + 1)}>
Click me
</button>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment