Last active
December 9, 2018 06:24
-
-
Save victors1681/184ee7f986e32e8d70707dbc0bc807f5 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 from "react"; | |
export default class Counter extends React.PureComponent { | |
state = { | |
counter: 0 | |
}; | |
increaseCounter = () => | |
this.setState(prevState => ({ counter: prevState.counter + 1 })); | |
render() { | |
return ( | |
<div> | |
<p>This is my counter</p> | |
<p>Counter is: {this.state.counter}</p> | |
<p> | |
<button onClick={this.increaseCounter}>Increase</button> | |
</p> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment