Created
June 9, 2016 16:55
-
-
Save nikolaymatrosov/536ccbcb4c8bc83ee314771f70de5d87 to your computer and use it in GitHub Desktop.
Arrow function example
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
export class Counter extends React.Component<any, any> { | |
constructor(props) { | |
super(props); | |
this.state = {count: props.initialCount}; | |
} | |
tick = () => { | |
this.setState({count: this.state.count + 1}); | |
} | |
render() { | |
return ( | |
<div onClick={this.tick}> | |
Clicks: {this.state.count} | |
</div> | |
); | |
} | |
} | |
Counter.propTypes = { initialCount: React.PropTypes.number }; | |
Counter.defaultProps = { initialCount: 0 }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original code from react docs