question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dompurify Error - "Could not load dompurify: ChunkLoadError: Loading chunk 1 failed."

See original GitHub issue

Hello, I’m getting an error with dompurify

image

const options = {
    orientation: "landscape",
    unit: "in",
    format: [3.93, 0.98]
}
const doc = new jsPDF({options});
doc.html(renderToString(printLayout), {
    callback: () => {
        doc.save();
    }
})

printLayout is a variable with JSX inside. renderToString returns a HTML String from printLayout.

How do I get rid of the error? Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
davidminecommented, Jun 18, 2021

@GunsyX , try this and let us know if it works

install dompurify and html2canvas with npm

Then use this code instead

import dompurify from 'dompurify';
import html2canvas from 'html2canvas';

const options = {
    orientation: "landscape",
    unit: "in",
    format: [3.93, 0.98]
}
const doc = new jsPDF({options});
doc.html(renderToString(printLayout), {
    callback: () => {
        doc.save();
    },
    html2canvas: html2canvas,
    dompurify: dompurify,
})
0reactions
prasheel888commented, Nov 10, 2022

@GunsyX , try this and let us know if it works

install dompurify and html2canvas with npm

Then use this code instead

import dompurify from 'dompurify';
import html2canvas from 'html2canvas';

const options = {
    orientation: "landscape",
    unit: "in",
    format: [3.93, 0.98]
}
const doc = new jsPDF({options});
doc.html(renderToString(printLayout), {
    callback: () => {
        doc.save();
    },
    html2canvas: html2canvas,
    dompurify: dompurify,
})

Error Gone but not getting CSS from External File, while Inline CSS Works! any suggestion man?

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Could not load dompurify: ChunkLoadError: Loading chunk 1 ...
Hello, I'm getting an error with dompurify const options = { orientation: "landscape", unit: "in", format: [3.93, 0.98] } const doc = new ......
Read more >
How to Solve the Chunk Load Error in JavaScript - Rollbar
Whenever there's an error observed in dynamically fetching helper JavaScript files known as Chunks, a ChunkLoad Error is thrown.
Read more >
Issue with jsPDF: Uncaught (in Promise) Error: Could not load ...
I think this is a problem with "sPDF will then dynamically load them (ie: dompurify and html2canvas) when required (using the respective module ......
Read more >
dompurify - npm
DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's written in JavaScript and works in all ...
Read more >
React — Loading Chunk Failed Error | by Tushar Mohan
Since an exception was recorded when the chunk failed to load, we will try loading the piece that failed. For that, let us...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found