Created
May 11, 2020 14:28
-
-
Save aabccd021/9ace312d86ecfd786946644f8ce26a3d 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
export class ContohUseState extends React.Component { | |
state = { count: 0 }; | |
render() { | |
const { count } = this.state; | |
return ( | |
<p> | |
<button onClick={() => this.setState({ count: count - 1 })}>-</button> | |
<b>{count}</b> | |
<button onClick={() => this.setState({ count: count + 1 })}>+</button> | |
</p> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment