Some more info for those curious and a quick reproduction.
Here’s the example straight from the Meteor 3 + React repo but with pieces commented out which seem to trigger additional renders and invocations of Meteor.subscribe.
export const Info = () => {
const isLoading = useSubscribe('links');
// const links = useFind(() => LinksCollection.find());
const links = [];
console.log('info')
/* if (isLoading()) {
return <div>Loading...</div>;
} */
return (
<div>
<h2>Learn Meteor!</h2>
<ul>{links.map(
link => <li key={link._id}>
<a href={link.url} target="_blank">{link.title}</a>
</li>
)}</ul>
</div>
);
};
// in client/main.jsx
const originalSubscribe = Meteor.subscribe;
Meteor.subscribe = function(name, ...args) {
console.log('subscribe invoked')
return originalSubscribe.call(this, name, ...args);
}
In the browser console:
Meteor.subscribe is invoked twice. I don’t see that behavior in other front ends or with a simple usage of useEffect + Tracker.autorun.
Beyond that, it gets worse if you uncomment isLoading and useFind. Is this expected behavior?
