diegomura / diegomura/react-pdf

usePdf Cannot read properties of null (reading 'props')

Open
#1,737 4 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

Package version: 2.0.20

When using **usePdf** hook, while gendering the PDF an error gets thrown.

Error message:
`TypeError: Cannot read properties of null (reading 'props')`

Stack track leads to:
- react-pdf.browser.es.js
`props = container.document.props || {};`

In the code itself I see define above:
```
var container = {
type: 'ROOT',
document: null
};
```

And accessing props on null can result in such an error.

The result is that for a split of second the **instance.error** returns an error which can be misleading for the user if we check for that property to show an error and after ±half a second the file gets generated and rendered successfully.

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.