react-pdf-highlighter icon indicating copy to clipboard operation
react-pdf-highlighter copied to clipboard

Uncaught (in promise) Error at PdfHighlighter.init

Open christophhalbi opened this issue 10 months ago • 4 comments

From time to time I get:

Uncaught (in promise) Error: ! at PdfHighlighter.init (react-pdf-highlighter.js?v=7deb8492:2123:13)

Thrown here:

if (!this.containerNodeRef.current) {
    throw new Error("!");
}

Am I doing anything wrong?

christophhalbi avatar Feb 05 '25 08:02 christophhalbi

Seems like a timing issue to me - checking containerNodeRef.current in init before ref is set in render

christophhalbi avatar Feb 05 '25 09:02 christophhalbi

Getting this issue as well, do you know what might be causing this, maybe I'm not waiting for the component to mount?

israel-arvizu avatar Mar 19 '25 05:03 israel-arvizu

Solution for me was to overwrite PdfHighlighter and add a little timeout to overcome the timing-issue.

https://gist.github.com/christophhalbi/40ce155e2bc326a1effafe746635a04a

christophhalbi avatar Mar 19 '25 06:03 christophhalbi

Solution for me was to overwrite PdfHighlighter and add a little timeout to overcome the timing-issue.我的解决方案是覆盖 PdfHighlighter 并添加一点超时以克服计时问题。

https://gist.github.com/christophhalbi/40ce155e2bc326a1effafe746635a04a

I also found this problem. I was going to directly modify the source code to solve it. Your scheme is very Nice.

liam-wen avatar Jul 16 '25 02:07 liam-wen