react-pdf
react-pdf copied to clipboard
`toBlob()` crashes when `undefined` is provided to <Text>'s render prop
Describe the bug
When using the Text component without providing a render prop it works as intended, as it does when providing a function. However, if provided with undefined it crashes when creating the blob ( pdf(doc).toBlob()). It throws a TypeError: node.props.render is not a function.
To Reproduce This works:
const doc = (
<Document>
<Page>
<Text>Something</Text>
</Page>
</Document>
);
const blob = await pdf(doc).toBlob();
This doesn't:
const doc = (
<Document>
<Page>
<Text render={undefined}>Something</Text>
</Page>
</Document>
);
const blob = await pdf(doc).toBlob();
Expected behavior
Even though it's probably not a common issue, it's useful to accept undefined if a variable that can be either a function or undefined is provided.
Desktop (please complete the following information):
- OS: Linux Mint
- Browser: Chrome
- React-pdf version 4.3.0
I'm having the same issue with the same React-pdf version