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

417
Vistas
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 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