Ademi
Ademi

Reputation: 340

Dynamically loading Quilljs

I'm trying to dynamically load Quilljs, however Firefox throws the error : Uncaught (in promise) TypeError: module.Quill is not a constructor

Although In QuillJs source code Quill (the default export) is a class with a constructor. What am I missing?

Here is my code so far:

import("quill").then(module => {
      let quill = new module.Quill('#quill-container', {
        modules: {...},
        .
        .
        .
      });      
    })

Upvotes: 1

Views: 619

Answers (1)

Narigo
Narigo

Reputation: 3101

I don't know Quill, but if it is exported through the default export (and there is a bundler in place that resolves import("quill") instead of having a relative or absolute URL), it should be possible to use it like this:

import("quill").then(module => {
  const Quill = module.default; // get the default export and name it to "Quill"
  let instance = new Quill(...);
  ...
});

Upvotes: 2

Related Questions