TypeError: Failed to fetch.
promotion-xu opened this issue · comments
promotion-xu commented
Before you start - checklist
- I followed instructions in documentation written for my React-PDF version
- I have checked if this bug is not already reported
- 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
"pdfjs-dist": "^2.16.105",
"react-pdf": "^6.0.0",
import { Document, Page } from 'react-pdf/dist/esm/entry.webpack'
import { pdfjs } from 'react-pdf'
import 'react-pdf/dist/esm/Page/TextLayer.css'
import 'react-pdf/dist/esm/Page/AnnotationLayer.css'
pdfjs.GlobalWorkerOptions.workerSrc = `https://cdn/xxxxxxxxxx/2.16.105_pdf.worker.min.js`
<Document
file={path}
onLoadError={err => console.log('loadError',err)}
onLoadSuccess={onDocumentLoadSuccess}
loading={<Spinner size={64} sx={{ position: 'absolute', top: '50%', transform: 'translateY(-50%)' }} />}
noData={<ErrorPage />}
>
{totalPageAry.map((ele) => (
<Page key={`pdf${ele}`} pageNumber={ele} />
))}
</Document>
Hi, team
I load the worker.js correctly, but it still load pdf failed. I am so strange , anyone can help me
Steps to reproduce
- install react-pdf@^6.0.0
- install pdfjs-dist@^2.16.105
- import and use
Expected behavior
expected load pdf correctly
Actual behavior
load pdf failed
Additional information
No response
Environment
- Browser (if applicable):
- React-PDF version: 6.0.0
- React version: 16.14.0
- Webpack version (if applicable):
Wojciech Maj commented
Where in the documentation was to install a specific pdfjs-dist version on your own? This is likely what broke it.
Please follow the documentation closely.