You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using react with typescript and I cant get this to work.
I have a form component where I want to display the selected pdf file.
The file got loaded, I got the File variable data. I tried to pass it is as a File to a Document file property, tried it to convert to base64 string, but always got the error:
Uncaught SyntaxError: Unexpected token '<'
Error: Setting up fake worker failed: "Cannot read property 'WorkerMessageHandler' of undefined".
I put here my relevant code
const[image,setImage]=useState<string>();const[imageFile,setImageFile]=useState<File>();const[pdfFile,setPdfFile]=useState<File>();const[pdf,setPdf]=useState<string>();const[pageNumber,setPageNumber]=useState<number>(1);const[numPages,setNumPages]=useState<number>();constonPdfPickHandler=(e: React.FormEvent<HTMLInputElement>): void=>{if(e.currentTarget.files?.item(0)){constfile=e.currentTarget.files.item(0);setPdfFile(file!);fileToPDF(file!);}}constfileToPDF=async(data: File): Promise<void>=>{const reader =newFileReader();reader.readAsDataURL(data);reader.onload=async()=>{setPdf(reader.resultasstring);}}{pdf&&<React.Fragment><Documentfile={pdf}onLoadSuccess={(e)=>onDocumentLoadSuccess(e)}><PagepageNumber={pageNumber}/></Document>{numPages&&<p>Page {pageNumber} of {numPages}</p>}</React.Fragment>}
The text was updated successfully, but these errors were encountered:
HI
I am using react with typescript and I cant get this to work.
I have a form component where I want to display the selected pdf file.
The file got loaded, I got the File variable data. I tried to pass it is as a File to a Document file property, tried it to convert to base64 string, but always got the error:
Uncaught SyntaxError: Unexpected token '<'
Error: Setting up fake worker failed: "Cannot read property 'WorkerMessageHandler' of undefined".
I put here my relevant code
The text was updated successfully, but these errors were encountered: