Hello. I’ve got a meteor project with react and flow router but there is a problem with the database: if I do a console.log(collection.find().fetch()) returns []. I removed autopublish so I publish my collection in the lib/collection.js file that I import in the server/main.js and I subscribe to it using FlowRouter in lib/routes.js that is imported in client/main.js:
In general, it is not recommended to run subscriptions on the router level in FlowRouter. Your code looks ok, though. But you don’t provide the code of the actual template calling the collection.find(). I guess the problem lies there.
Oh okay. The collection.find is in the action() in the router: http://pastebin.com/jx8734Hj
The ProjectsComponent has a propTypes called projects of type PropTypes.array
if it’s not recommended to run the subscriptions in FlowRouter, where should I run it?
Thank you this helped a lot. Now I subscribe in FlowRouter in action() using the tracker and it works but using a form in the same page, it doesn’t automatically update. Why is that?
Thank you I’ve read again the meteor guide and I finally understood. I now have a createContainer. That’s where I subscribe to my collection that I return to my component