-
-
Notifications
You must be signed in to change notification settings - Fork 886
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
react-pdf v2 and react-virtualized #49
Comments
Hey, |
Here's the full stack trace: Yeah, I agree. Seems like quite a rough way to go about things. But that is how |
Thanks for all the information! :) PS. I'm waiting for your feedback and I'm releasing 2.0.0, enough of that beta stage ;) |
No, unfortunately that did not help. Looking at the stack trace again, it seems like it might be the I can make a little sample project with react-virtualized + react-pdf if that would make it easier for you. Let me know. And thanks for all your work on this. |
Aw, shoot. We're getting somewhere though as I see that onPageError does not throw a warning anymore! |
Here's a little sample project. Install it with:
I've tested it on latest Chrome together with http-server to serve my pdf over http. You should see the I also noticed react-virtualized performance on Firefox is pretty poor (pdf is flickering on scroll). I was kind of baffled by this at first, as my original project seems to do just fine on Firefox, but then I remembered I am using my fork of react-pdf for my original project where I have added a small optimisation to shouldComponentUpdate(nextProps, nextState) {
return nextState.page !== this.state.page;
} Thanks! |
Hey @michaeldzjap, I was playing for several hours with the demo you've sent me but I cannot find the root of this issue. Did some small fixes for the next release but I doubt they will help. Somehow cancelled promises are still called. I could do some hacks (actually, pretty simple ones) to get it working but I'd really want it to be done properly and I can't pin the issue down. Whatever renders those components is behaving super crazy... Can't even find a deterministic logic behind it. The components throwing errors seem to change every so often. |
Thanks @wojtekmaj. I wanted to take a crack at this myself the other week, but ended up being too busy with other work. I did just now try one thing, which seemed to do the trick actually! I got the idea from reading this. Basically, I have introduced an
I think using an I do realise that my use case might be a bit specific and perhaps you don't want to mess up your code with a somewhat hacky solution. Although you could also argue that using a virtualization lib together with react-pdf is the saner choice when you want to display pdf's with a lot of pages. What do you think? By the way; I made a repository for a sample project that uses react-pdf + react-virtualized. Its a bit cleaner than the .zip I included previously here. |
I have investigated this issue a bit more. It is not an explanation for how to fix this more cleanly (i.e. not using an I won't go into too much detail here about react-virtualized, but the main culprit of the issue turned out to be the I have updated the sample project repository to reflect the changes for those who are interested. So in conclusion, although I haven't found a real solution for this issue, I have found a way to make react-pdf and react-virtualized play nice together. Since this was my original objective this issue can be closed as far as I am concerned. |
By this change GitHub may be able to recognize the repository license and show it in the header.
I am trying to use the new version of this lib together with react-virtualized. As far as I can test so far I have managed to get this working with a fully responsive pdf viewer. The only problem is that I receive multiple (depending on the number of pages of the pdf) React warnings of the form
I have tried to track this down myself and although I am not sure about this at all, it seems it might be related to the fact that I use the
CellMeasurer
component from react-virtualized. From the react-virtualized documentation:Not very clear how this is done, but I suspect that maybe this rendering is happening very fast and perhaps
is not cancelling "quick" enough (i.e.
setState({})
inonLoadSuccess()
/onLoadError()
is called even thoughPage
has unmounted already). But at this point this is more speculation than something that I have been able to accurately verify. I also understand that this is not really a react-pdf issue per se, but nonetheless I was wondering if there perhaps is anyone who could shed some light on this matter.The text was updated successfully, but these errors were encountered: