question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use DownloadLink with the code in the docs

See original GitHub issue

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior including code snippet (if applies):

  1. Go to https://react-pdf.org/advanced#dynamic-content/#on-the-fly-rendering
  2. Run the code inside the Download Link section:
import { PDFDownloadLink, Document, Page } from '@react-pdf/renderer'

const MyDoc = () => (
  <Document>
    <Page>
      // My document data
    </Page>
  </Document>
)

const App = () => (
  <div>
    <PDFDownloadLink document={<MyDoc />} fileName="somename.pdf">
      {({ blob, url, loading, error }) => (loading ? 'Loading document...' : 'Download now!')}
    </PDFDownloadLink>
  </div>
)

I’ve also tried putting <div>Test text</div> instead of the comment inside the Page component.

  1. I get index.js:1 TypeError: Cannot read property 'height' of undefined at setNodeHeight in the console
  2. The link is stuck at ‘Loading document…’

You can make use of react-pdf REPL to share the snippet

Expected behavior A clear and concise description of what you expected to happen.

The link to turn into a clickable, downloadable link that supplies the pdf.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS Catalina 10.15.14
  • Browser Chrome Version 83.0.4103.61 (Official Build) (64-bit)
  • React-pdf version 2.0.0-beta.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Nickman87commented, Oct 1, 2020

I had the same issue, reverting back to 1.6.11 was not an option but I think I found my problem:

I had two children inside a <Text> node like this: <Text>{"some string"} other string</Text?

Removing this solved the issue for me

2reactions
diegomuracommented, Apr 22, 2021

So many things going on at the same time here 😅

@ys27 if you are running that exactly, it will fail since // My document data it’s not a valid react-pdf child. The example is simplified for demo purposes, I thought that was clear sorry. You should use View, Image, Text or other primitives inside the page

@german-st You are rendering dom nodes inside the PDF document. You should stick with the react-pdf primitives that are in the doc. This is not an html renderer

@akshaykatariyaa based on your comment you are also trying to render dom components to PDF. You should stick to react-pdf primitives as well. react-pdf does not provide a way to transform existing components to react-pdf primitives.

Anyone feel free to create another issue but I think all these (somehow unrelated) things were answered 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix file download errors - Google Chrome Help
To fix the error: Cancel the download and try again. Instead of clicking the file to download, right-click the link and select Save...
Read more >
How to fix Google Drive not downloading files - Setapp
Try a few ways to download files · Use a single Google account to log in · Download a file in private browsing...
Read more >
How to fix the "cannot download file" issue in Google Drive on ...
If you've found your Chromebooks are refusing to download files from your Google Drive account, Jack Wallen has the fix for you.
Read more >
Python: download files from google drive using url
Show activity on this post. I am trying to download files from google drive and all I have is the drive's URL. I...
Read more >
Download files | Google Drive
The following code snippet shows how to download a file with the Drive API client libraries. Note: If you're using the older Drive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found