Last active
August 29, 2015 14:21
-
-
Save kitten/071846f7c09654ae98f4 to your computer and use it in GitHub Desktop.
React ES6 Code Samples for Medium #3
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
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