Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

336
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda