Uncaught TypeError: Eo is not a function with PDFDownloadLink [repro included]
Describe the bug
Using <PDFDownloadLink document={doc} /> will crash with Uncaught TypeError: Eo is not a function as soon as as the key attribute of any node within doc changes.
To Reproduce A minimal reproduction can be found at https://github.com/warrenfalk/react-pdf-issue-repro
- git clone https://github.com/warrenfalk/react-pdf-issue-repro
- cd react-pdf-issue-repro
- pnpm install
- pnpm run dev
- Click the button
- Page blanks because of error, open dev console to see the error
- See src/App.tsx
This is due to the key={count}. If you remove this, the error goes away
Note: it would be easy to remove the key attribute in this repro of course, but it is not possible to remove it in rendering arrays and similar situations, of course, which is where we encountered this bug.
Expected behavior It does not crash.
Screenshots
Desktop (please complete the following information):
- OS: Linux, (but seems to happen everywhere)
- Browser Chrome
- React-pdf version "@react-pdf/renderer": "^4.3.0"
- React 19
Same issue here, I'm trying to pass an array of rows. Pushing to the array is fine, but removing a row I get this same error.
I managed to solve the problem using this
// Utility to generate a simple hash of the services to use as a key
function getServicesKey(services: CleaningService[]): string {
// You can use only the IDs and dates for the hash
return services
.map((s) => `${s.id}-${s.generalDate instanceof Date ? s.generalDate.toISOString() : s.generalDate}`)
.join('|');
}