react-pdf: Page component is not reloading when PDF source changes.
Before you start - checklist
- I followed instructions in documentation written for my React-PDF version
- I have checked if this bug is not already reported
- I have checked if an issue is not listed in Known issues
Description It’s not reloading Page component when dynamically changing pdf source.
On 3.0.5
// Component will recieve props
if (
this.getPdf(nextProps, nextContext) !== this.getPdf() ||
this.getPageNumber(nextProps) !== this.getPageNumber()
)
How i think it might work (using lodash.eq)
// Component will recieve props
if (
!eq(this.getPdf(nextProps, nextContext), this.getPdf()) ||
this.getPageNumber(nextProps) !== this.getPageNumber()
)
Steps to reproduce I’m using the system to load multiple Documents and load a small version of all its pages bellow that (just like the sample). When clicking on the small page it shows a preview of the clicked page. If I click on pages that has the same pageNumber but different documents, it doesn’t update the preview component. It seems that it has a simple !== . This operation checks only for reference, and not for the equality of the object, since the reference inside the component is never changing, it evaluates to false every time. Check additional information
Expected behavior It should reload Page component when changing the source pdf.
Additional information When clicking on 1st page of pdf_sample_2 and then on 1st page of pdf_sample_1 it should render the preview from pdf_sample_1. *It works for different pageNumbers.
)
Environment
- Browser Chrome: 57
- React-PDF version: 3.0.5
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (7 by maintainers)
I’m on
v5.0.0
and react17.0.1
& I use Next.js. I’m having the same issue. When I save the file, the pdf document does not get updated unless I refresh by hand.