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

Image under View render prop Not working #1936

Open
Belkacem opened this issue Jul 13, 2022 · 4 comments
Open

Image under View render prop Not working #1936

Belkacem opened this issue Jul 13, 2022 · 4 comments

Comments

@Belkacem
Copy link

Describe the bug
Image under View render prop we get this error message : Error: TypeError: Cannot read properties of undefined (reading 'width')

To Reproduce
Repl link

Expected behavior
Should display an Image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser chrome,
  • React-pdf version 2.3.0
@gervitz
Copy link

gervitz commented Jul 28, 2022

I did const Quixote = () => ( <Document> <Page style={styles.body}> <View> <Image style={styles.image} src="/images/quijote1.jpg" /> </View> </Page> </Document> );

and it worked fine. Not sure why you do <View render={() => <Image style={styles.image} src="/images/quijote1.jpg" /> } fixed />

@Belkacem
Copy link
Author

Belkacem commented Jul 29, 2022

I need to render an image only on some pages

@gervitz
Copy link

gervitz commented Jul 29, 2022

If I've understood this dependency correctly, you need to do it manually.
const Quixote = () => ( <Document> <Page style={styles.body}> <View> <Image style={styles.image} src="/images/quijote1.jpg" /> </View> </Page> <Page style={styles.body}> <View> <Image style={styles.image} src="/images/quijote1.jpg" /> </View> </Page> <Page style={styles.body}> <Text>Hello World</Text> </Page> </Document> );

@Belkacem
Copy link
Author

Thanks for the effort, but your suggestion doesn't resolve the problem.
even if my use case has another solution, there's clearly a bug here and FYI it was working on older versions of react-pdf.
Cheers :-)

tigerza117 added a commit to tigerza117/react-pdf that referenced this issue Jul 5, 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