ReactiveDict is undefined


my Problem is that I am currently trying to access a ReactiveDict in an EventListener inside the same Template. The creation in my onCreated seems to work. But when I am trying to access it it is always undefined. Can anybody please have a look?

Event Listener:{
    'click .minus1'(event, instance) {
        const id = this._id;

        const current = instance.zahlen.get(id);
        instance.zahlen.set(id, current - 1);

onCreated function:

Template.bierwart_getrankezahlen.onCreated(() => {
    const template = this;
    template.zahlen = new ReactiveDict();


What is undefined: instance.zahlen or id?

instance.zahlen is undefined.
Sorry for being not precise

Your code looks correct.

What is the exact error message in your console log?

getrankezahlen.js:26 Uncaught TypeError: Cannot read property 'get' of undefined
    at .minus1 (getrankezahlen.js:26)
    at blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:3818
    at Function.Template._withTemplateInstanceFunc (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:3769)
    at Blaze.View.<anonymous> (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:3817)
    at blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:2617
    at Object.Blaze._withCurrentView (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:2271)
    at Blaze._DOMRange.<anonymous> (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:2616)
    at HTMLButtonElement.<anonymous> (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:863)
    at HTMLElement.dispatch (modules.js?hash=0a505f8664c68b3ed522d3b90b1ce95e4ec8bc87:39917)
    at HTMLElement.elemData.handle (modules.js?hash=0a505f8664c68b3ed522d3b90b1ce95e4ec8bc87:39725)

Is the full error log in the console.

Hmm. And just to be certain, you have done meteor add reactive-dict?

It was my initial thought as well so I stopped my App and ran the command.

Okay - I’ve just seen the problem. You can’t use fat arrows in onCreated or onRendered, so Template.bierwart_getrankezahlen.onCreated(() => { needs to be Template.bierwart_getrankezahlen.onCreated(function() {


Yeah, arrow functions by definition bind the definition of this, which prevents Blaze from giving you the template instance as this