Skip to content

Instantly share code, notes, and snippets.

@kitten
Last active August 29, 2015 14:21
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 kitten/071846f7c09654ae98f4 to your computer and use it in GitHub Desktop.
Save kitten/071846f7c09654ae98f4 to your computer and use it in GitHub Desktop.
React ES6 Code Samples for Medium #3
import { PropTypes } from "react";
import { CompatComponent } from "react-compat-component";
export default class HelloWorld extends CompatComponent {
getMixins() {
return [
DummyMixin
];
}
getInitialState() {
return {
world: "World"
};
}
getPropTypes() {
return {
food: PropTypes.array
};
}
getDefaultProps() {
return {
food: [ "Pizza", "Lasagna", "Sushi" ]
};
}
_onClick() {
this.setState({
world: "Cthulhu"
});
}
render() {
return (
<h1 onClick={this._onClick}>
Hello {this.state.world}!
</h1>
<ul>
{
this.props.food.map(obj => <li>{obj}</li>);
}
</ul>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment