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

usePDF hook incompatibility on 3.1.12 release #2333

Open
pitmullerIngka opened this issue Jun 15, 2023 · 2 comments · May be fixed by #2334
Open

usePDF hook incompatibility on 3.1.12 release #2333

pitmullerIngka opened this issue Jun 15, 2023 · 2 comments · May be fixed by #2334

Comments

@pitmullerIngka
Copy link

Describe the bug
We update patches automatically in our projects, since we expect them to be backwards compatible and not require us to do manual changes.
However, #2247 was released as a patch, even though it requires users of the previous usePDF hook manual changes that are not mentioned anywhere.

To Reproduce
Previous usage (based on test in #2247):

# const [instance, updateInstance] = usePDF(
-   { document: doc }
# );
# useEffect(
-   updateInstance,
#   [doc]
# );

New usage:

# const [instance, updateInstance] = usePDF(
+ 
# );
# useEffect(
+   () => updateInstance(doc),
#   [doc]
# );

Expected behavior
Backwards compatibility on a patch or release as a minor or even major version, which mentions required changes for affected users.

Desktop (please complete the following information):

  • OS: Linux
  • Browser firefox, chromium
  • React-pdf version v3.1.12
@jeetiss jeetiss linked a pull request Jun 15, 2023 that will close this issue
@jeetiss
Copy link
Collaborator

jeetiss commented Jun 15, 2023

@pitmullerIngka thanks for your report and sorry about broken backward compatibility.

Could you please approve that fix #2334 would work for your use case?

@pitmullerIngka
Copy link
Author

Thanks for the quick reply and excuse my delayed response.

I've set it up locally now with your branch and it doesn't seem to have resolved the issue that occurred with the previous configuration.

My code before looked like this:

const [instance, renderPdf] = usePDF({
  document: (
    <PDFDocument {...props} />
  ),
});

useEffect((): void => {
  if (visible) {
    setTimeout(renderPdf, 1);
  }
}, [visible]);

If I run that with the current change, I still get an error response:

An error occurred while loading the PDF.

PDF.js v3.6.126 (build: 3f89a99a5)
Message: Invalid page request.

All that said, it is not relevant for me at least, that this previous approach is still usable, but rather some notice and documentation on how to adjust, if you're experiencing issues with it, might be sufficient.

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

Successfully merging a pull request may close this issue.

2 participants