-
-
Notifications
You must be signed in to change notification settings - Fork 901
Upgrade guide from version 1.x to 2.x
Wojciech Maj edited this page Mar 18, 2018
·
2 revisions
Instead of a single ReactPDF
component, there are now two: Document
and Page
. Thanks to this change, you can render multiple pages while still loading the file just once.
Consider this basic example:
1.x
<ReactPDF
file={file}
pageIndex={0}
/>
2.x
<Document file={file}>
<Page pageIndex={0} />
</Document>
A lot of changes in version 2.x was around callbacks. In version 1.x, callbacks were not very robust. For example, onPageError
was called in two distinct situations.
Removed prop | Replaced with prop | Comments |
---|---|---|
onDocumentError |
onLoadError in Document
|
|
onDocumentLoad |
onLoadSuccess in Document
|
|
onPageLoad |
onLoadSuccess in Page
|
|
onPageRender |
onRenderSuccess in Page
|
|
`onPageError |
onLoadError and onRenderError in Page
|