Created
April 14, 2019 20:11
-
-
Save YKalashnikov/7bdd66b69b5da8df48ff02ac3bb36303 to your computer and use it in GitHub Desktop.
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'; | |
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