Skip to content

Instantly share code, notes, and snippets.

@victors1681
Last active December 9, 2018 06:24
Show Gist options
  • Save victors1681/184ee7f986e32e8d70707dbc0bc807f5 to your computer and use it in GitHub Desktop.
Save victors1681/184ee7f986e32e8d70707dbc0bc807f5 to your computer and use it in GitHub Desktop.
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