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

toBlob() crashes when undefined is provided to <Text>'s render prop #3122

Open
vinibanaco opened this issue Mar 7, 2025 · 0 comments
Open

Comments

@vinibanaco
Copy link

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
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

1 participant