-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Describe the bug
Encountering a TypeScript error TS2769: No overload matches this call when using PDFDownloadLink. The error suggests that the provided ({loading}: { loading: any; }) => Element is not assignable to the expected type ReactNode | ReactElement<BlobProviderParams, string | JSXElementConstructor<any>>.
To Reproduce
Steps to reproduce the behavior:
-
Use
PDFDownloadLinkwith the following setup:import { PDFDownloadLink } from '@react-pdf/renderer'; const MyDocument = () => ( <Document> <Page> <Text>Hello, world!</Text> </Page> </Document> ); const DownloadLink = () => ( <PDFDownloadLink document={<MyDocument />} fileName="example.pdf"> {({ loading }) => (loading ? 'Loading...' : 'Download PDF')} </PDFDownloadLink> );
-
Run
tscor start the application. -
Observe the TypeScript error:
TS2769: No overload matches this call. Overload 1 of 2, (props: PDFDownloadLinkProps | Readonly<PDFDownloadLinkProps>): PDFDownloadLink, gave the following error. Type ({loading}: { loading: any; }) => Element is not assignable to type ReactNode | ReactElement<BlobProviderParams, string | JSXElementConstructor<any>>. Overload 2 of 2, (props: PDFDownloadLinkProps, context: any): PDFDownloadLink, gave the following error. Type ({loading}: { loading: any; }) => Element is not assignable to type ReactNode | ReactElement<BlobProviderParams, string | JSXElementConstructor<any>>.
Expected behavior
The PDFDownloadLink should correctly accept the child render function and render "Loading..." while the document is being prepared or "Download PDF" when ready.
Desktop (please complete the following information):
- OS: [Windows]
- Browser: [Edge]
- React-pdf version: [4.1.6]
- TypeScript version: [5.6.2]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
