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

Using an Image within the render function of a View causes the render process crash #2064

Open
pganster opened this issue Oct 28, 2022 · 5 comments

Comments

@pganster
Copy link

pganster commented Oct 28, 2022

Describe the bug
Using <Image /> within the render() function of a View causes the render process to crash and the following error message is shown: Error: TypeError: Cannot read properties of undefined (reading 'width').

To Reproduce

  1. Use an image within the render function: <View render={() => <Image src="/images/quijote1.jpg" />} />
  2. The rendering crashes

In this REPL you can see the crash in action.

Expected behavior
The rendering should not crash and the image should be rendered. I'm using the render function, so I can render an image on every page except on the first page.

Desktop (please complete the following information):

  • OS: Linux
  • Browser: No Browser, I'm generating PDFs in a NodeJS context.
  • React-pdf version: v3.0.0
@ZabeehUllah
Copy link

I am facing the same issue. I am unable to render dynamic image. Have you found the solution?

@pganster
Copy link
Author

No I haven't and there are many issues regarding this and I don't hink this will be fixed.

#1936
#1630
#1587
#1369

@ZabeehUllah
Copy link

@pganster any alternative library that might work better for such scenario?

@pganster
Copy link
Author

@ZabeehUllah You can try working with pdfjs, which react-pdf uses underneath. But I have no idea whether this use case is possible or not with that library. I ended up displaying the image on every page.

@ZabeehUllah
Copy link

Okay, I will give it a try. Thank you anayway.

mskec pushed a commit to mskec/react-pdf that referenced this issue Mar 10, 2023
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

No branches or pull requests

2 participants