A <Page/> component with a pdf prop causes an error if it is not inside a <Document/> component #1709
Closed
3 of 4 tasks
Labels
bug
Something isn't working
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
The text was updated successfully, but these errors were encountered: