I\'m extending a base class and overriding a method in the base class. But when I call it, it calls the super class version. How do I override the method?
I found the answer (adapted from here: https://gist.github.com/Zodiase/af44115098b20d69c531 ) - the base class needs to also be defined in an ES6 manner:
class Hello extends React.Component {
//abstract getName()
getName()
{
if (new.target === Hello) {
throw new TypeError("method not implemented");
}
}
render() {
return This is: {this.getName()};
}
};