[X] I followed instructions in documentation written for my React-PDF version
[X] I have checked if this bug is not already reported
[X] I have checked if an issue is not listed in Known issues
[ ] If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo
Description
I need to display the pages of several pdf documents in one common block. The <Document/> component places the pages of each pdf file in a separate block.
In the documentation I read the following:
Displays a page. Should be placed inside . Alternatively, it can have pdf prop passed, which can be obtained from 's onLoadSuccess callback function, however some advanced functions like linking between pages inside a document may not be working correctly.
That is, as far as I understood,<Page/> can not be wrapped in <Document/>, but simply transfer pdf props.
But when I try to display the page like this -
<Page
pdf={pdf}
otherProps
/>
Then I get the following error -Invariant failed: Unable to find Document context. Did you wrap <Page /> in <Document />?
I get the pdf props in the onLoadSuccess function:
onLoadSuccess={(pdf) => onDocumentLoadSuccess(pdf, otherArguments)
Before you start - checklist
Description
I need to display the pages of several pdf documents in one common block. The
<Document/>
component places the pages of each pdf file in a separate block.In the documentation I read the following:
That is, as far as I understood,
<Page/>
can not be wrapped in<Document/>
, but simply transfer pdf props.But when I try to display the page like this -
Then I get the following error -
Invariant failed: Unable to find Document context. Did you wrap <Page /> in <Document />?
I get the pdf props in the onLoadSuccess function:
onLoadSuccess={(pdf) => onDocumentLoadSuccess(pdf, otherArguments)
But for example, if you do it like this:
testPdf1 I just import into the app:
import testPdf1 from './test.pdf'
testPdf2 I get from the onLoadSuccess callback.Then everything will work and page 1 will be displayed from testPdf2.
Steps to reproduce
Try this code to reproduce the error:
Expected behavior
A
<Page/>
component with a pdf prop is expected to work without a<Document/>
wrapperActual behavior
An error occurs:
Invariant failed: Unable to find Document context. Did you wrap <Page /> in <Document />?
Additional information
No response
Environment