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

416
Visualizações
Why are JavaScript functions from an imported class not defined using WebPack (Uncaught ReferenceError: function is not defined)

I am trying to call a function from an imported class in my index.js using WebPack like this:

import TetrisController from './js/Controller/tetrisController';

let tetris = new TetrisController();
tetris.runTetris();

TetrisController:

export class TetrisController {

    constructor() {
    ...
    }

    setuctxList() {
        let list = [];
        for (let i = 0; i < ucanvasList.length; i++) {
            uctxTemp = ucanvasList[i].getContext('2d');
            list.push(uctxTemp);
        }
        return list;
    }

    runTetris() {
        uctxList = setuctxList();
        addEvents(); // attach keydown and resize events

        function frame() {
            drawNext();
            requestAnimationFrame(frame);
        }

        reset();
        drawBottom();
        resize();
        frame();
    }

}

export default TetrisController;

The problem is that it returns a Uncaught ReferenceError which says the function setuctxList() is not defined.

The console error: main.js:2 Uncaught ReferenceError: setuctxList is not defined at Object.runTetris (main.js:2:71774)

I think it has something to do with WebPack but I do not know for sure. What is going wrong here?

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