I have the following on line 163:
this.setState(data)
Then right below it I have this:
(function(data){
setTimeout(() => {
// do some stuff
}, 5)
}).call(this, data)
When I comment out the latter, it all works fine. When I leave it there, for some reason I get an undefined error coming from line 163, saying this.setState is not a function.
Also when I simply replace the second snippet with
setTimeout(() => {
// do stuff
}, 5)
again, it works fine (except for the fact that sometimes the data variable isn't what it should be... not always though, weird).
How is this happening? How can code that hasn't been executed yet make this.setState
undefined? I even checked in the debugger and this is set to what it should be right before it throws the error... am I missing something here?