Pdf page links do not work since 5.4.0
Before you start - checklist
- [x] I followed instructions in documentation written for my React-PDF version
- [x] I have checked if this bug is not already reported
- [x] I have checked if an issue is not listed in Known issues
- [x] If I have a problem with PDF rendering, I checked if my PDF renders properly in Mozilla Firefox
Description
In the version 5.4.0 page links in a pdf were broken such that clicking on them does not take them to the desired page.
Instead an error is displayed in the console:
LinkService.js:71 Uncaught (in promise) TypeError: dest.then is not a function
at LinkService.js:71
at new Promise (<anonymous>)
at LinkService.goToDestination (LinkService.js:67)
at HTMLAnchorElement.link.onclick (pdf.js:17534)
Console log of "dest" from within LinkService.goToDestination: [{num: 57, gen: 0}, {name: 'XYZ'}, 0, 841.89, null]
Steps to reproduce
Steps to reproduce the behavior:
- Open codesandbox or file example_045.pdf in react-pdf
- Click on Chapter 2 in the table of contents.
Expected behavior
When clicking on chapter 2, the user should be sent to the page titled: "Chapter 2" or codesandbox, it will alert the pagenumber.
Additional information
Testing in codesandbox shows issue appeared in version v5.4.0-beta.2
If my understanding of promise is correct, then changing this line LinkService.js#L58 in LinkService.js to resolve(dest) should be a valid fix if dest can be either a value or a promise. It did fix it for me.
Environment
- Browser (if applicable) Chrome 94,
- React-PDF version 5.4.0
- React version [e.g. 16.3.0]: 17.0.2
- Webpack version (if applicable) [e.g. 4.16.2]: Unknown
I'm also experiencing this
Fixed in v5.4.1. Thanks for reporting, and providing excellent examples to work with!