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

Reloading the document on every prop change #383

Closed
3 tasks done
jsardev opened this issue Apr 4, 2019 · 4 comments
Closed
3 tasks done

Reloading the document on every prop change #383

jsardev opened this issue Apr 4, 2019 · 4 comments
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@jsardev
Copy link

jsardev commented Apr 4, 2019

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

<Document /> reloads the document on every prop change when you're passing an object to the file prop.

Steps to reproduce

Pass an object to file prop.

Expected behavior

In the code below, the file check should consider being an object, which in most cases will be everytime something new, as {} !== {}.

componentDidUpdate(prevProps) {
const { file } = this.props;
if (file !== prevProps.file) {
this.loadDocument();
}
}

Environment

  • React-PDF: 4.0.5
  • React: 16.8.6
@jsardev
Copy link
Author

jsardev commented Apr 4, 2019

The workaround is to:

Instead of:
<Document file={{ url: '/name.pdf', withCredentials: true }} />
do:
<Document file="/name.pdf" options={{ withCredentials: true }} />

@wojtekmaj
Copy link
Owner

Duplicate of #308

@wojtekmaj wojtekmaj marked this as a duplicate of #308 Apr 8, 2019
@wojtekmaj wojtekmaj added bug Something isn't working duplicate This issue or pull request already exists labels Apr 8, 2019
@jsardev
Copy link
Author

jsardev commented Apr 9, 2019

@wojtekmaj Oeps, sorry, I missed it 😢

@pavan-singh-iphtech
Copy link

The workaround is to:

Instead of: <Document file={{ url: '/name.pdf', withCredentials: true }} /> do: <Document file="/name.pdf" options={{ withCredentials: true }} />

not work in case of re ordering pdf

@wojtekmaj wojtekmaj added question Further information is requested and removed bug Something isn't working labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants