This is how my code looks
index.html:
<canvas></canvas>
main.js:
import Class from "./module.js"
export const canvas = document.querySelector("canvas")
const obj = new Class(args)
module.js:
import { canvas } from "./main.js"
const c = canvas.getContext("2d")
export default class Class{
// code
}
This is the error: Uncaught ReferenceError: Cannot access 'canvas' before initialization (in module.js)
What am I doing wrong?
tried with import function and some other stuff but that's not really efficient.