I am trying to display a pdf on my web page using the react-pdf library, however whenever I try to load the page I get the following error:
Uncaught SyntaxError: Unexpected token '<'
at handleError (http://localhost:3000/static/js/bundle.js:187976:58)
at http://localhost:3000/static/js/bundle.js:187995:7
And I don’t really know what this means and all of my other pages work other then this one, here is my code if anyone can help:
import React from "react";
import { Document, Page } from "react-pdf";
const ResumeDisplay = () => {
return (
<div>
<Document
file={
"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
}
>
<Page pageNumber={1} />
</Document>
</div>
);
};
export default ResumeDisplay;
2
Answers
FIX: I imported pdfjs and needed to use useEffect for the url as React thought it was rendering multiple times:
Try replacing
<
with<
.