Last active
June 7, 2018 19:09
-
-
Save agenthunt/6496bd5ac6ddbe15f47f912a2d455e09 to your computer and use it in GitHub Desktop.
hello-react-custom-renderer-counter.js
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'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
counter: 0 | |
}; | |
} | |
render() { | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
<img src={logo} className="App-logo" alt="logo" /> | |
<h1 className="App-title">Welcome to React</h1> | |
</header> | |
<p className="App-intro"> | |
<div className="button-container"> | |
<button className="decrement-button" onClick={() => this.setState({ counter: this.state.counter - 1 })}> | |
- | |
</button> | |
<div className="counter-text">{this.state.counter}</div> | |
<button className="increment-button" onClick={() => this.setState({ counter: this.state.counter + 1 })}> | |
+ | |
</button> | |
</div> | |
</p> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment