Cannot read property 'dereference' of undefined
See original GitHub issueI’m just trying a simple example to download a PDF with a PDFDownloadLink and its throwing the above error when the component renders.
const ReportPDF = () => (
<Document>
<Page size="A4">
<View>
<Text>Section #1</Text>
</View>
<View>
<Text>Section #2</Text>
</View>
</Page>
</Document>
);
...
render (
<div>
<PDFDownloadLink document={<ReportPDF/>} fileName="somename.pdf">
{({loading}) => loading ? <Button>Loading</Button> : <Button>PDF</Button>}
</PDFDownloadLink>
</div>
)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:33 (3 by maintainers)
Top Results From Across the Web
Unhandled Rejection (TypeError): Cannot read property '' ...
You are trying to get a post with an id that doesn't exists. Looking at how .find works it will return undefined if...
Read more >Cannot read properties of undefined (reading '0')
Specifically, this error occurs more often on our Data Deployer Application pages. Cause. You see this error because new orgs in Salesforce ......
Read more >cannot read properties of undefined (reading 'datatransfer')
TypeError : Cannot read property 'setData' of undefined. The undefined here is the dataTransfer object. You can use the jest manual mocks to...
Read more >7 Tips to Handle undefined in JavaScript
TypeError: 'undefined' is not a function; TypeError: Cannot read property '<prop-name>' of undefined; and alike type errors.
Read more >Understanding reactivity
MobX reacts to any existing observable property that is read during the execution of a tracked function. "reading" is dereferencing an object's property, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Apparently you should render it only once, so just use “useMemo”:
I’ve been playing with react-pdf or around two weeks now and I mostly get these type of errors if rendering is interrupted.
Try preloading everything before trying to render with react-pdf. It seems that re-renders are a common cause for problems.
That includes fonts, images (urls are fine though), async data. Fetch it all in your container and THEN render the PDF for the best results.