I have a js script that works fine on its own, however when I try to move my code to reactjs the nested/referenced function loses 'this' and it references window instead. Pseudo code bellow. Any idea what causes this? I figure its related to webpack or something reactjs is doing?
lib.AnMovieClip = function() {
this.testVariable = true;
this.gotoAndPlay = function(){
// 'this' works here perfectly fine
this.otherFunction();
}
this.otherFunction(){
// returns undefined, as 'this' is now the window object
console.log(this.testVariable);
}
}