Last active
January 14, 2016 18:55
-
-
Save danott/29b36824c7b605e40fd4 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
-const Something = ({ name }) => { | |
- const localAction = () => console.log(name) | |
+const Something = React.createClass({ | |
+ propTypes: { | |
+ name: React.PropTypes.string.isRequired | |
+ }, | |
- return <div onClick={localAction}>Log {name}</div> | |
+ localAction() { console.log(this.props.name) }, | |
+ | |
+ render() { | |
+ return <div onClick={this.localAction}>Hello {this.props.name}</div> | |
+ } | |
} |
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
-const Something = ({ name }) => { | |
- const localAction = () => console.log(name) | |
+class Something = extends React.Component { | |
+ constructor(props) { | |
+ super(props) | |
+ this.localAction = () => console.log(this.props.name) | |
+ } | |
+ render() { | |
+ return <div onClick={this.localAction}>Hello {this.props.name}</div> | |
+ } | |
+} | |
- return <div onClick={localAction}>Log {name}</div> | |
+Something.propTypes = { | |
+ name: React.PropTypes.string.isRequired | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment