wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
9.11k stars 867 forks source link

Cannot set properties of undefined (setting 'workerSrc') #1662

Closed panwaranuj01 closed 2 months ago

panwaranuj01 commented 9 months ago

Before you start - checklist

Description

TypeError: Cannot set properties of undefined (setting 'workerSrc')\n at ./node_modules/react-pdf/dist/esm/index.js

import React, { useState } from "react";
import { Document, Page, pdfjs } from 'react-pdf';

import "react-pdf/dist/esm/Page/AnnotationLayer.css";
import "react-pdf/dist/esm/Page/TextLayer.css";
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.js`;

Steps to reproduce

I have just imported this

Expected behavior

My react app should load

Actual behavior

My react app is not loading

Additional information

No response

Environment

tonykhaov commented 8 months ago

Hey did you check that you don't have pdfjs-dist in your package.json? I had the same issue and fixed it by removing pdfjs-dist dependency

neerajkatiyar commented 6 months ago

@wojtekmaj Could you please provide us a fix for v5.7.2

wojtekmaj commented 6 months ago

@wojtekmaj Could you please provide us a fix for v5.7.2

Sorry, not a chance. This version is no longer supported. I don't have capacity to maintain multiple versions.

neerajkatiyar commented 6 months ago

No problem, I can understand, we will upgrade to the latest version. Thanks

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] commented 2 months ago

This issue was closed because it has been stalled for 14 days with no activity.