Last active
September 6, 2016 02:41
-
-
Save scionwest/e828ebde1e27844b2c1efd5b02fb1b08 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 from 'react'; | |
| import {render} from 'react-dom'; | |
| import Button from './Button.jsx'; | |
| import Result from './Result.jsx'; | |
| class App extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = {likesCount: 0}; | |
| } | |
| onLike(increment) { | |
| let newLikesCount = this.state.likesCount + increment; | |
| this.setState({likesCount: newLikesCount}); | |
| } | |
| render() { | |
| return ( | |
| <div> | |
| <p>Hello From React!</p> | |
| <Button onClicked={() => this.onLike()} increment={1} /> | |
| <Button onClicked={() => this.onLike()} increment={5} /> | |
| <Button onClicked={() => this.onLike()} increment={10} /> | |
| <Button onClicked={() => this.onLike()} increment={100} /> | |
| <Result count={this.state.likesCount}/> | |
| </div> | |
| ); | |
| } | |
| } | |
| render(<App />, document.getElementById('app')); |
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 from 'react'; | |
| class Result extends React.Component { | |
| render() { | |
| return ( | |
| <div>{this.props.count}</div> | |
| ); | |
| } | |
| } | |
| export default Result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment