diegomura / diegomura/react-pdf
Provide PDFDownloadLink some sort of prop that supports lazy or conditional loading?
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Hey everyone, first off I want to say that this package is really impressive, thanks for maintaining it. Also, if going to go off on assumptions regarding this feature, so excuse me if I got anything wrong. Now on topic, I've noticed that, as expected, generating PDF files is a costly operation, performance wise. So during render, a lot of files are fetched and since my generated PDF is dynamic, the performance takes a hit due to every re-render. To optimize this behavior I currently have to do workarounds from an upper scope of the `PDFDownloadLink` component, for example.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Either delay or debounce the initial PDF generation. I think an awesome feature would be to wait X amount of seconds until the PDF should start to load, and if there is a re-render or a change in the passed props to the document prop of the `PDFDownloadLink` component, then simply hold it off and/or restart the timer. Basically, debounce.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
As I mentioned earlier, either debouncing it or delaying it. I guess throttling might work fine as well but throttling doesn't seem appropriate for this use-case. Passing a `shouldLoad` prop would work wonders too, but it would require external logic on an upper scope.
Contributor guide
Assessment
This issue has not been assessed yet.