Last active
October 18, 2025 14:34
-
-
Save nightcoder26/ee23670a5cc0dc29abbfba5c6c6b9af5 to your computer and use it in GitHub Desktop.
Example react class component
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
| class Component extends React.Component{ | |
| constructor(props) | |
| { | |
| super(props); | |
| this.state = {count:0}; | |
| } | |
| increment = () => | |
| { | |
| this.setState({count: this.state.count + 1}); | |
| } | |
| render() | |
| { | |
| return( | |
| <div> | |
| <h1>Count: {this.state.count}</h1> | |
| <button onClick={this.increment}>+</button> | |
| </div> | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment