#Why is this property undefined?

1 messages · Page 1 of 1 (latest)

queen bone
#

Here's a pastebin of my file: https://pastebin.com/Gi9HBBW4

The property lastTime is defined as 0. But when I create this object, I get this error:

TypeError: Cannot read properties of undefined (reading 'lastTime')

This error happens at line 37: const elapsedTimeMs = time - this.lastTime;

Nothing else in the code turns that property undefined, so why is it?

restive juniper
#

this.rive.requestAnimationFrame(this.renderLoop);
doing this unbinds this.
use this.renderLoop.bind(this) or (...args) => this.renderLoop(...args) (or pass the relevant args specifically)

#

the error says this is undefined, not this.lastTime.
can't read properties of undefined, reading 'lastTime' of undefined, the thing before is undefined.

queen bone
#

this strikes again

#

ty for the help, i gotta learn more about it

#

using this.renderLoop.bind(this) worked perfectly btw