Image under View render prop Not working
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
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 />
I need to render an image only on some pages
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> );
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 :-)