2016-02-16 15:40:37 +09:00
|
|
|
// import React from 'react';
|
|
|
|
|
|
|
|
const ItemContainer = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
collection: React.PropTypes.object.isRequired,
|
|
|
|
component: React.PropTypes.func.isRequired,
|
2016-02-16 16:12:13 +09:00
|
|
|
publication: React.PropTypes.string.isRequired,
|
2016-02-16 15:40:37 +09:00
|
|
|
terms: React.PropTypes.object
|
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [ReactMeteorData],
|
|
|
|
|
|
|
|
getMeteorData() {
|
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
const subscription = Meteor.subscribe(this.props.publication, this.props.terms);
|
2016-02-16 15:40:37 +09:00
|
|
|
|
|
|
|
return {
|
|
|
|
results: this.props.collection.findOne(this.props.terms)
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const Component = this.props.component; // could be Post or PostEdit
|
|
|
|
|
|
|
|
if (this.data.results) {
|
|
|
|
return (
|
|
|
|
<Component {...this.data.results} />
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return <p>Loading…</p>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = ItemContainer;
|