Last active
August 30, 2016 14:00
-
-
Save nicolaslopezj/c5a449a648a344605238737dc0a3bdf5 to your computer and use it in GitHub Desktop.
This file contains 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
// with-post.js | |
import {withData} from 'meteor/orionsoft:react-meteor-data' | |
import {Meteor} from 'meteor/meteor' | |
import Posts from './posts' | |
export default withData(({postId}) => { | |
Meteor.subscribe('post', postId) | |
const post = Posts.findOne(postId) | |
return {post} | |
}) | |
// with-author.js | |
import {withData} from 'meteor/orionsoft:react-meteor-data' | |
import {Meteor} from 'meteor/meteor' | |
import Authors from './authors' | |
export default withData(({post}) => { | |
if (!post) return {} | |
Meteor.subscribe('author', post.authorId) | |
const author = Authors.findOne(itemId) | |
return {author} | |
}) | |
// my-component.js | |
import React from 'react' | |
import withPost from './with-post.js' | |
import withAuthor from './with-author.js' | |
@withPost | |
@withAuthor | |
export default class Component extends React.Component { | |
render () { | |
if (!this.props.post || !this.props.author) return <span>Loading...</span> | |
return ( | |
<div> | |
{this.props.post.title} by {this.props.author.name} | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment