Skip to content

Failed to fetch dynamically imported module #573

@izzabellerina

Description

@izzabellerina

Sorry for this error, it's kind of newbie error , but I searched and don't know how to fix it .Even AI like chatGPT didn't work
Could you help me? I appreciate any help you can provide.

Uncaught TypeError: Failed to fetch dynamically imported module: http://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.1.91/pdf.worker.mjs
at handleError (http://localhost:3000/static/js/bundle.js:43441:58)
at http://localhost:3000/static/js/bundle.js:43460:7

import React, { useState, useRef } from 'react';
import { usePdf } from '@mikecousins/react-pdf';

function App() {
const [page, setPage] = useState(1);
const canvasRef = useRef(null);

const { pdfDocument } = usePdf({
file: './test.pdf',
page,
canvasRef,
});

return (


{!pdfDocument && Loading...}

{pdfDocument && (



  • <button disabled={page === 1} onClick={() => setPage(page - 1)}>
    Previous



  • <button
    disabled={page === pdfDocument.numPages}
    onClick={() => setPage(page + 1)}
    >
    Next




)}

);
}

export default App;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions