Next.js Discord

Discord Forum

Cannot update component (''HotReload") while rendering different component ("Router")

Unanswered
Spectacled bear posted this in #help-forum
Open in Discord
Spectacled bearOP
I saw a similar post, but it pertained to next 13. I want to stick to next 14 due to server actions.

Here is the snippet
useEffect(() => { if (file) { extractData(file); } }, [file]); const onFileChange = async (event) => { setFile(event.target.files[0]); }; return <input type="file" onChange={(event) => onFileChange(event)} />;

and the snippet for the extractData which uses tabula-js
export const extractData = async (base64) => { const buffer = Buffer.from(base64, "base64"); // Write the file to the local file system const filePath = path.join(__dirname, "temp.pdf"); await writeFile(filePath, buffer); // Read the PDF file from the file system const pdfData = await readFile(filePath); // Use tabula-js to extract the data from the PDF const t = tabula(pdfData, {pages: 'all'}); const data = await t.extract(); console.log(data) return data; };

0 Replies