diegomura / diegomura/react-pdf

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

Open
#3,122 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

**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:
```jsx
const doc = (


Something


);
const blob = await pdf(doc).toBlob();
```

This doesn't:
```jsx
const doc = (


Something


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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.