Created
August 12, 2022 15:55
-
-
Save vsim1964/37fc34d2be93a2950a5cc8b9577fa313 to your computer and use it in GitHub Desktop.
React__4 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
import React, { Component } from 'react' | |
export default class Clicker extends Component { | |
// constructor(props) { | |
// super(props) | |
// this.state = { | |
// count: 0 | |
// } | |
// } | |
state = { | |
count: 0 | |
} | |
handler = () => { | |
this.setState({ count: this.state.count + 1 }) | |
} | |
render() { | |
return ( | |
<> | |
<button onClick={this.handler}> | |
{this.state.count} | |
</button> | |
</> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment