Last active
August 29, 2015 14:21
-
-
Save kitten/15ca74e537584d2d7d9e to your computer and use it in GitHub Desktop.
React ES6 Code Samples for Medium #1
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
var React = require("react"); | |
var HelloWorld = React.createClass({ | |
mixins: [ | |
DummyMixin | |
], | |
getInitialState: function() { | |
return { | |
world: "World" | |
}; | |
}, | |
propTypes: { | |
food: React.PropTypes.array | |
}, | |
getDefaultProps: function() { | |
return { | |
food: [ "Pizza", "Lasagna", "Sushi" ] | |
} | |
}, | |
_onClick: function() { | |
this.setState({ | |
world: "Cthulhu" | |
}); | |
} | |
render: function() { | |
return ( | |
<h1 onClick={this._onClick}> | |
Hello {this.state.world}! | |
</h1> | |
<ul> | |
{ | |
this.props.food.map(function(obj) { | |
return <li>{obj}</li>; | |
}); | |
} | |
</ul> | |
); | |
} | |
}); | |
module.exports = HelloWorld; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment