Last active
June 19, 2021 05:08
-
-
Save ejangi/21c16c7ff740757282dd968991eb378b to your computer and use it in GitHub Desktop.
No need to work with useState() when you have a react component class.
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
export default class Example extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
count: 0 | |
}; | |
} | |
render() { | |
return ( | |
<div> | |
<p>You clicked {this.state.count} times</p> | |
<button onClick={() => this.setState({ count: 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