I used to sub and fetch and return data in getMeteorData
, but, it seems ineffective. For example, if I subscribe('items')
, and let items = Items.find({}).fetch()
, every time a new item is added, the find
is rerun totally.
Here’s an example from my app:
getMeteorData() {
const projectId = FlowRouter.getParam("_id")
const taskId = FlowRouter.getParam("taskId")
const taskLoaded = Meteor.subscribe("taskDetails", projectId, taskId)
.ready()
return {
taskLoaded,
task: Tasks.findOne({_id: taskId})
}
},
Then you reference this.data.task
in your render()
function
this is the normal way to use ReactMeteorData, but I found it ineffective. it will auto rerun every time Tasks collection changed.