diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.73k stars 1.17k forks source link

BindingError #2892

Open jonnny013 opened 4 days ago

jonnny013 commented 4 days ago

I recently ran the latest update (4.0.0) and everything works fine, but I get the annoying bug in the console for a binding error: "Expected null or instance of Config, got an instance of Config" Stack trace[0] Error. (http://localhost:3000/node_modules/.vite/deps/@react-pdf_renderer.js?v=5fc542da:85453:13)

It doesn't seem to be causing any issues, I just like to keep the console clean and I don't have a clue what the issue is.

I am happy to add on more information, but I don't know what information would be helpful for this.

jstorm31 commented 4 days ago

I started getting this error too with @react-pdf/renderer@3.4.5.

Edit: upgrading to version 4.0.0 didn't help.

Edit 2: I was rendering multiple PDFs with Promise.all. Generating them sequentially in for...of loop helped.

pontageorge commented 3 days ago

I get this error and the PDViewer actually fails to render my PDF ocassionally and I have no idea why.

HuguesBlanco commented 3 days ago

I’m encountering the same issue

I use a <Document> component in both a <PDFViewer> and a <PDFDownloadLink>, and it seems that rendering them simultaneously might be causing the error.

If I remove one, the error goes away.
Rendering them sequentially, as @jstorm31 suggested, also fixes it. (I tested this using a setTimeout).

Are you all also using multiple <Document> components?

pontageorge commented 3 days ago

I was the same way as you with a <PDFViewer> and a <PDFDownloadLink>. Now I just have the PDFViewer, still encountering the issue unfortunately. Also, update to the PDF state don't trigger a rerender of the PDFViewer, not sure if it's related or not or it wasn't supposed to do that anyways.

FastRives commented 3 days ago

Hello everyone,

I encountered the same issue and resolved it by redefining the <img /> component. The previous version no longer accepted a src with a URL, so to fix the problem, I converted my image into a Base64 string, and now it works good.

I'm not sure if you're facing the same issue, but this approach might be worth exploring.

Best regards, FastRives.

HuguesBlanco commented 2 days ago

Hi everyone,

After further investigation, I came across this pull request, which provides more insight into the issue: https://github.com/diegomura/react-pdf/pull/2878. It appears that the problem is related to Yoga's initialization. A fix has been submitted and is currently awaiting merge.

luokelong commented 1 day ago

Hi everyone,

After further investigation, I came across this pull request, which provides more insight into the issue: #2878. It appears that the problem is related to Yoga's initialization. A fix has been submitted and is currently awaiting merge.

I encountered the same problem. But the difference with you is that the problem mentioned in #2890 also occurred at all the time, and this BindingError occurred only some time. I'm guessing there's some connection between these two issues.

Without a doubt, you are the best.

JohnFoster44 commented 1 day ago

I'm getting this error on Firefox just using the PDFDownloadLink. Stopping the PDF from being downloaded unless I refresh.

HuguesBlanco commented 15 hours ago

Hi everyone, After further investigation, I came across this pull request, which provides more insight into the issue: #2878. It appears that the problem is related to Yoga's initialization. A fix has been submitted and is currently awaiting merge.

I encountered the same problem. But the difference with you is that the problem mentioned in #2890 also occurred at all the time, and this BindingError occurred only some time. I'm guessing there's some connection between these two issues.

Without a doubt, you are the best.

@luokelong, I haven’t encountered the second error you mentioned. Regarding the first issue, I agree that it varies. Sometimes it happens once, other times twice. I suspect this variation is due to how long my machine takes to load and render the documents, which might affect the error trigger.