diegomura / diegomura/react-pdf

usePdf triggers re-generating all pdf documents previously generated by another components

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

Description

I have multiple components using usePdf to generate pdf on user click. But once some is already ready (download link is displayed) and user clicks on another - all instances regenerate.

Example:
```
export default function Doc1PdfGenerator (props: IDoc1Props) {
const [instance] = usePDF({ document: });
const href = instance.url ?? undefined;

return (
<>
Open pdf

{instance?.error && PDF file unavailable}
{instance?.loading && !instance.error && Creating PDF file ...}

)
}

export default function Doc2PdfGenerator (props: IDoc2Props) {
const [instance] = usePDF({ document: });
...
}
```

The first component added to the page - doc1 is generated. 2nd component added to the page - doc2 is generated and doc1 is also regenerated.

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.