Skip to content

Instantly share code, notes, and snippets.

@AppleCEO
Created September 6, 2020 19:28
Show Gist options
  • Save AppleCEO/0dda1a5a4073f153b9e3de04d5fb408e to your computer and use it in GitHub Desktop.
Save AppleCEO/0dda1a5a4073f153b9e3de04d5fb408e to your computer and use it in GitHub Desktop.
import React from "react";
import "./styles.css";
export default function App() {
return <Counter />;
}
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {
value: 0
};
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState({
value: this.state.value + 1
});
}
render() {
return (
<div>
<h2>{this.state.value}</h2>
<button onClick={this.handleClick}>Press Me</button>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment