Created
January 14, 2018 22:03
-
-
Save shubich/22d08c5e54a5509cc8a8ff0d02705725 to your computer and use it in GitHub Desktop.
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
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
import './style.css'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
count: 0, | |
}; | |
} | |
inc = () => { | |
this.setState({ | |
count: this.state.count + 1, | |
}) | |
} | |
dec = () => { | |
this.setState({ | |
count: this.state.count - 1, | |
}) | |
} | |
render() { | |
return ( | |
<div> | |
<div>{this.state.count}</div> | |
<button onClick={this.inc}>+</button> | |
<button onClick={this.dec}>-</button> | |
</div> | |
); | |
} | |
} | |
render(<App />, document.getElementById('root')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackblitz.com/edit/react-jmx3a7?file=index.js