Skip to content

Instantly share code, notes, and snippets.

@nightcoder26
Last active October 18, 2025 14:34
Show Gist options
  • Select an option

  • Save nightcoder26/ee23670a5cc0dc29abbfba5c6c6b9af5 to your computer and use it in GitHub Desktop.

Select an option

Save nightcoder26/ee23670a5cc0dc29abbfba5c6c6b9af5 to your computer and use it in GitHub Desktop.
Example react class component
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