Open
Description
I'm using useTracker
like this:
<div>{!contact ? null : (
<AsyncValue
subscription={{
name: 'mail.contactStats',
args: [contact.ID],
query: () => MailStats.findOne({ _id: `for-contact-${contact.ID}` }),
}}
/>
)}</div
export function AsyncValue({ promise, subscription, render, children, onError }) {
const [error, setError] = useState(null);
const { name, args, query } = subscription;
const value = useTracker(
() => {
LOG('METEOR TRACKER?', subscription);
if (error) return undefined; // otherwise we get an infinite loop trying to resubscribe
// I COMMENTED MY WHOLE CODE TO NARROW DOWN THE PROBLEM, IT STILL APPEARS
// const sub = Meteor.subscribe(name, ...args, {
// onStop: error => {
// if (onError) {
// DEBUG(`AsyncValue subscription error, sending to onError:`, error);
// onError(error, setError);
// } else {
// if (error) console.error('AsyncValue Subscription error:', error);
// setError(error);
// }
// },
// });
// DEBUG(`sub: ready=${sub.ready()}, entries:`, query);
// return sub.ready() ? query() : undefined;
return undefined;
}
[]
);
DEBUG(`sub value:`, value);
const renderValue = () => (render ? render(value) : value);
return <>{value !== undefined ? renderValue() : placeholder()}</>;
}
Works fine if contact is set from the start - but whenever contact
changes from being null to non-null, this error occurs:
Uncaught Error: Can't set timers inside simulations
at withoutInvocation (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:621:13)
at bindAndCatch (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:633:33)
at Meteor.defer (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:694:24)
at useTracker.ts:163:12
at mountMemo (modules.js?hash=bfdeb58d2ee948751f18b6466ad43663c2847a1e:133794:19)
at Object.useMemo (modules.js?hash=bfdeb58d2ee948751f18b6466ad43663c2847a1e:134090:16)
at useMemo (modules.js?hash=bfdeb58d2ee948751f18b6466ad43663c2847a1e:113407:21)
at useTrackerWithDeps (useTracker.ts:137:3)
at useTrackerClient (useTracker.ts:206:12)
at useTrackerDev (useTracker.ts:244:16)
Also tried useTracker
with subscription as dep (same error as above) and without deps - which causes this error:
Uncaught Error: Can't set timers inside simulations
at withoutInvocation (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:621:13)
at bindAndCatch (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:633:33)
at Meteor.defer (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:694:24)
at useTrackerNoDeps (useTracker.ts:81:12)
at useTrackerClient (useTracker.ts:204:12)
at useTrackerDev (useTracker.ts:244:16)