Skip to content

Instantly share code, notes, and snippets.

@danott
Last active January 14, 2016 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danott/29b36824c7b605e40fd4 to your computer and use it in GitHub Desktop.
Save danott/29b36824c7b605e40fd4 to your computer and use it in GitHub Desktop.
-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>
+ }
}
-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