Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No doc rerender while uploading a new one #283

Open
ksalpern opened this issue Aug 1, 2024 · 2 comments
Open

No doc rerender while uploading a new one #283

ksalpern opened this issue Aug 1, 2024 · 2 comments

Comments

@ksalpern
Copy link

ksalpern commented Aug 1, 2024

Hey, thank you a lot for this lib, it made my life easier with PDFs!)

I had an issue in my app, I have input for PDF files. It work perfectly for the first time, but when I want to upload a new file, file name changes, file URL also changes but document preview itself doesn't change. I checked your Storybook with PDF input and as you can see, the same result here.

2024-08-01.14-05-20.mp4
@zshnrg
Copy link

zshnrg commented Aug 5, 2024

I have a similar issue but I experienced it when some documents that have been fetched want to be displayed according to user's choice, the pdf is not re-rendered. For my case, this solution can solve the issue by adding a key to DocViewer with a value of file name

Hope this solution can help in your case

@SuperZ3
Copy link

SuperZ3 commented Aug 5, 2024

I found PDFRender use mainState from PDFProvider like this:

https://github.com/cyntler/react-doc-viewer/blob/bd5f92563f2e168c4cc1181546bb300bb18be5bc/src/renderers/pdf/components/pages/PDFPages.tsx#L13C1-L19C62

but in PDFProvider, it combines mainState with state only at initial time and not update any more:

https://github.com/cyntler/react-doc-viewer/blob/bd5f92563f2e168c4cc1181546bb300bb18be5bc/src/renderers/pdf/state/index.tsx#L26C3-L38C6

so i think we can update mainState either in useEffect or obtain it from PDFProvider like this <PDFContext.Provider value={{ state, dispatch, mainState }}>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants