please help me! Don’t know why this wouldn’t work:
class Parent {
render() {
console.log('parent')
}
}
class Child extends Parent {
static cRender() {
this.render()
}
}
Child.cRender() // error msg: this.render is not a function
at Function.cRender
I thought i could access the method in the Parent
class like that.
i did some trial and error:
class Parent {
render() {
console.log('parent')
}
}
class Child extends Parent {
cRender() {
this.render()
}
}
const child = new Child()
child.cRender() // works. But i don't properly understand why the first wouldn't work
class Parent {
static render() {
console.log('parent')
}
}
class Child extends Parent {
static cRender() {
this.render()
}
}
Child.cRender() // this also works with static methods in both - i don't really get