Skip to content

Instantly share code, notes, and snippets.

@YKalashnikov
Created April 14, 2019 20:11
Show Gist options
  • Save YKalashnikov/7bdd66b69b5da8df48ff02ac3bb36303 to your computer and use it in GitHub Desktop.
Save YKalashnikov/7bdd66b69b5da8df48ff02ac3bb36303 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
class Counter extends Component {
constructor() {
super();
this.state = {
count: 1
};
}
handleClick = () => {
this.setState(prevState => ({count: prevState.count + 1}))
}
render() {
const { count } = this.state;
return (
<div>
<h3 className="center">
Welcome to the Counter of Life
</h3>
<button className="center-block" onClick={this.handleClick}>
{count}
</button>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment