Alcumus / react-doc-viewer

Apache License 2.0
208 stars 101 forks source link

PDFRenderer error: Can't perform a React state update on an unmounted component #80

Open ironbyte opened 3 years ago

ironbyte commented 3 years ago

Hi, I get the following error message which causes the PDF page viewer UI to collapse. It happens when the component is re-rendered which is triggered via a React state update. It seems that the error originates from PDFRenderer plugin component.

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
    in Document (created by Styled(Document))
    in Styled(Document) (created by PDFPages)
    in PDFPages (created by PDFRenderer)
    in div (created by styled.div)
    in styled.div (created by PDFRenderer)
    in PDFProvider (created by PDFRenderer)
    in PDFRenderer (created by Contents)
    in Contents

I'm able to reproduce this issue in my code sandbox - (https://codesandbox.io/s/affectionate-feistel-zpfhn). Ignore Failed to load PDF file error. Codesandbox doesn't support loading a PDF file from an external source.

arpitprod commented 2 years ago

pdf file content-type is application/javascript and it should be application/pdf then file will be load fine.

Screenshot 2021-09-09 at 20 52 22
jaijagwani commented 1 year ago

I am also facing the same issue. Has someone found a fix for it? @ironbyte