Skip to content

Instantly share code, notes, and snippets.

@vsim1964
Created August 12, 2022 15:55
Show Gist options
  • Save vsim1964/37fc34d2be93a2950a5cc8b9577fa313 to your computer and use it in GitHub Desktop.
Save vsim1964/37fc34d2be93a2950a5cc8b9577fa313 to your computer and use it in GitHub Desktop.
React__4 Class
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