react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Cannot set properties of undefined (setting 'workerSrc')

Open panwaranuj01 opened this issue 7 months ago • 5 comments

Before you start - checklist

  • [X] I followed instructions in documentation written for my React-PDF version
  • [X] I have checked if this bug is not already reported
  • [X] I have checked if an issue is not listed in Known issues
  • [X] If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

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

  • Browser (if applicable):
  • React-PDF version: "^7.5.1"
  • React version:" 16.9.0"
  • Webpack version (if applicable):

panwaranuj01 avatar Nov 08 '23 10:11 panwaranuj01