diegomura / diegomura/react-pdf
BlobProvider in loop
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
After updating to v2.0 appeared an unexpected behavior in BlobProvider: during rendering on the fly, the props "loading" and "url" changes continuously, making the document re-render multiple times, as you can see in the following screenshot:

BlobProvider is located in the parent component "ReportGenerator.js", the document is located in the child component "MyDocument". Here an extract of my code:
```
}
>
{({ blob, url, loading, error }) => {
console.log(blob, url, "loading:", loading, "error:", error);
if (error) {
return {error};
}
else if (!blob) {
return (
Loading...
);
} else {
return (
}
document={
}
fileName={`${props.kitData._id}.pdf`}
>
{" "}
);
}
}}
```
In MyDocument component there is no state change, just StyleSheet.create method and React Pdf components taking data from props. Props and states in parent component don't change as well.
After this multiple re-rendering, the pdf at last appears. Moreover, if I use Dynamic content, like the page number in a footer, the re-rendering go in infinite loop, crashing the browser tab.
Have you and idea why this is happening? Thank you so much in advance!
Desktop:
- OS: [Windows]
- Browser [chrome]
- React-pdf version [2.0.12]
Contributor guide
Assessment
This issue has not been assessed yet.