Skip to content

Instantly share code, notes, and snippets.

@ilkka
Forked from kimmobrunfeldt/prepare-null.js
Last active August 29, 2015 14:16
Show Gist options
  • Save ilkka/8b826b7ccdf0907ec0f6 to your computer and use it in GitHub Desktop.
Save ilkka/8b826b7ccdf0907ec0f6 to your computer and use it in GitHub Desktop.
// IndexComponent.jsx
var Index = React.createClass({
propTypes: {
products: React.PropTypes.array.isRequired
},
getDefaultProps: function getDefaultProps() {
return {
products: []
};
},
render: function render() {
var items = this.props.products.map(function (p) {
return (<div key={p.id}>
<h1>{p.description}</h1>
<h2>{p.consumption}</h2>
</div>);
});
return (
<div className="page">
{items}
</div>
);
}
});
somehowAsynchronously(function () {
getMyData().then(function (data) {
somehowRenderMyIndexComponentWithProps({
products: data.products
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment