Last active
February 6, 2019 15:08
-
-
Save jsalonen/2f8496c9ded478062f4882567cdf8632 to your computer and use it in GitHub Desktop.
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'; | |
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