I just wanted to point out that sometimes this error happens because a function has been used as a high order function (passed as an argument) and then the scope of this
got lost. In such cases, I would recommend passing such function bound to this
. E.g.
this.myFunction.bind(this);
More Related Contents:
- Javascript object members that are prototyped as arrays become shared by all class instances
- ES6 – declare a prototype method on a class with an import statement
- Prototypical inheritance – writing up [duplicate]
- What are the nuances of scope prototypal / prototypical inheritance in AngularJS?
- ES6 class variable alternatives
- Defining methods via prototype vs using this in the constructor – really a performance difference?
- JS : Convert Array of Strings to Array of Objects
- How to extend a class without having to use super in ES6?
- ES6 arrow functions not working on the prototype?
- Declaring static constants in ES6 classes?
- Extending an Object in Javascript
- How to get class object’s name as a string in Javascript?
- Create an instance of a class in ES6 with a dynamic name? [duplicate]
- What is the difference between class method vs. class field function vs. class field arrow function?
- Can I construct a JavaScript object without using the new keyword?
- Override a setter, and the getter must also be overridden
- Object vs Class vs Function
- How to access object prototype in javascript?
- React functional components vs classical components
- Adding Prototype to JavaScript Object Literal
- Re-associating an object with its class after deserialization in Node.js
- Can you create functions with custom prototypes in JavaScript?
- Advantages of setting the “constructor” Property in the “prototype”
- What does the new keyword do under the hood?
- JS call static method from class
- JS defineProperty and prototype
- How to add mixins to ES6 javascript classes?
- [[Prototype]] vs prototype: ..what is the difference? (MyCons.__proto__ === MyCons.prototype) equals FALSE
- prototypal inheritance concept in javascript as a prototype based language
- jQuery match part of class with hasClass