Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

328
Vistas
React Extending a class I get "classCallCheck.js:3 Uncaught TypeError: Cannot call a class as a function"

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}>);
    }
};
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda