-
Notifications
You must be signed in to change notification settings - Fork 169
Description
Perhaps I'm missing something here, but I'm having a spot of bother with v2.2.1. I'm new to react, Javascript and Meteor, so please don't bite!
I recently updated my project to Meteor 2.0. After seeing all the warnings in the logs from withTracker RE undefined deps array, I separately updated react-meteor-data to 2.2.1 as the warnings were due to a bug that was fixed in 2.2.1
I'm using useTracker to tell me when a Meteor subscription is ready, like this:
const projectsReady = useTracker(() => {
const subscription = Meteor.subscribe('projects')
return subscription.ready()
}, [])
But when using Meteor Dev tools to watch DDP messages, I see that there are 2 'Subscribing to projects' going off to the server. I don't really see why as I have an empty dependancy array rather than no dependancies. Sure enough, logging on the server shows me that 2 subscription requests arrived there. As a note, the subscription handles I get back had different IDs, but I thought that Tracker.autorun took care of that behind the scenes (looking at Meteor Docs)?
Just to be silly, I did this to see what would happen:
useTracker(() => {
console.log('Hello world');
},[])
And, I get 'Hello world' in my log twice (the function is not rendering due to a props change, BTW).
Final note: this didn't used to happen in version 2.1.1 (98% sure of that).
My concern is is two fold - First the extra Subscribes (and corresponding unsubscribes that happen right after) and also the unnecessary renders this causes.
Am I missing something? Is it a bug? Something else?
Looking forward to an expert opinion.