vyky
1
Suppose I have:
tracking() {
Tracker.autorun(() => {
if (someMeteorReactiveVariable()) {
// do something
};
});
}
How do I stop above tracker when component unmount?
I’m asking to stop tracker because Tracker will always rerun even though component has already unmounted and creating unnecessary warning.
sashko
2
tracking() {
this.computation = Tracker.autorun(() => {
if (someMeteorReactiveVariable()) {
// do something
};
});
}
componentWillUnmount() {
this.computation.stop();
}
Alternatively, you can use createContainer
or getMeteorData
, which stop things for you when the component unmounts.
2 Likes