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

Debounced method called with different contexts

Open dkazakov8 opened this issue 1 year ago • 6 comments

Hello,

I just upgraded to version 7.0.0, and when I resize the window, this error appears in the console: "Uncaught Error: Debounced method called with different contexts." This occurs inside the "debounce" library, and the root cause is this line. The debouncedScaleValue method has no bound context, so when it's used in ResizeObserver or addEventListener, it has different contexts.

It seems like this error doesn't negatively affect functionality; it just spams the console with errors. this.debouncedScaleValue = this.debouncedScaleValue.bind(this) helps, maybe someone could include it in a PR.

ksnip_20240712-212106

dkazakov8 avatar Jul 12 '24 19:07 dkazakov8

Thanks, I'll take a look. Does the 7.0.0 work fine for you otherwise?

agentcooper avatar Jul 13 '24 12:07 agentcooper

Thanks, I'll take a look. Does the 7.0.0 work fine for you otherwise?

Please update it if there's time . Thank you

youlandEric avatar Jul 15 '24 08:07 youlandEric

Thanks, I'll take a look. Does the 7.0.0 work fine for you otherwise?

Yes, thanks. Everything else is working fine. The only difference from version 6.1.0 in my use cases was an incorrect z-index for the annotations layer (annotations are not clickable), which I fixed with:

.PdfHighlighter__highlight-layer {
  z-index: 3 !important;
}

dkazakov8 avatar Jul 16 '24 10:07 dkazakov8

Also encountering this issue on 7.0.0, any update?

israel-arvizu avatar Jul 18 '24 00:07 israel-arvizu

Same here, having the same issue

codepeach avatar Jul 20 '24 15:07 codepeach

Simple bandaid solution is to replace:

debouncedScaleValue: () => void = debounce(this.handleScaleValue, 500); in PdfHighlighter.tsx with debouncedScaleValue = this.handleScaleValue;

Keep in mind that removing debouncing may result in severe performance losses for resizing functionality.

NathanHam16 avatar Jul 26 '24 00:07 NathanHam16

Same here, having the same issue

WangTing121314 avatar Sep 13 '24 05:09 WangTing121314

I switched to a different debounce library in 8.0.0-rc.0.

agentcooper avatar Sep 14 '24 17:09 agentcooper