Created
September 6, 2020 19:28
-
-
Save AppleCEO/0dda1a5a4073f153b9e3de04d5fb408e to your computer and use it in GitHub Desktop.
This file contains hidden or 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"; | |
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