Here is the parent class:
export default class RosterTableUtil{
constructor() {
let highLightCellIndex = -1, highLightRowIndex = -1;
................
this.updateUI = (cellIndex, rowIndex) => {
highLightCellIndex = cellIndex;
highLightRowIndex = rowIndex;
}
}
}
Here is the child class:
import RosterTableUtil from "./RosterTableUtil";
export default class RosterSchedulerTableUtil extends RosterTableUtil{
constructor(){
super();
.............
this.updateUI = (cellIndex, rowIndex) => {
super.updateUI(cellIndex, rowIndex);
updateSelectRegion(cellIndex, rowIndex);
}
}
}
When the RosterSchedulerTableUtil.updateUI function is called, I got the following error:
Uncaught TypeError: (intermediate value).updateUI is not a function
How can I fix the problem?
2
Answers
To fix the problem, you need to add a super() call to the beginning of the updateUI function in the child class.
Updated to use private fields.
It’s not obvious to me why you’d want to do all of that within the constructor. Seems like that’s what instance methods are for. You could move it out of the constructor like this: