Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

418
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!