I found many questions and answers for this but I believe mine's slightly different.
All I want to do is use the Base Class A functionality in the inherited child Class B, but I want to use a different functionality for the method Cell. With older Webpack versions, it worked fine, but the newer versions of Webpack rises an "Uncaught TypeError: Cannot call a class as a function". The code of Webpack catches the error is
export default function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
I read that it has to do with the class instance and using a new keyword is the way to make it work. In my case, using the last solution, I lose all the functionality of the Base Class A creating new types of errors because Base Class is already used as an instance from the other parts of the applications and it keeps its own states. I tried from example code like this
const C = new B() and return (<C param1={x}>); but it didn't work either. Any recommendations?
Here is a simplified version of my code.
/****************BASE CLASS********************************/
const A = (props) => {
const Cell = ({ p: row }) => {
return ..........
};
}
export default A;
/*************CHILD CLASS**********************************/
import { B } from 'baseClass';
export default class B extends A {
Cell = ({ p: row }) => {
return ..........
};
}
/*************MAIN**********************************/
import React, { Component } from 'react';
import B from 'childClass';
const List = class extends Component {
render() {
return (<B param1={x}>);
}
};