Critical dependency warning when using react-pdf Critical dependency warning when using react-pdf reactjs reactjs

Critical dependency warning when using react-pdf


This code will display your pdf file, but issue will display in IDE console.

import { Document, Page, pdfjs } from "react-pdf";pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;

In my case I'm using webpack 4 and it's not supportted yet.If you build project it will work fine.


My full workaround.Create a file at the root called config-overrides.js and it should contain the following:module.exports = function override(config) {config.module.rules[0].parser.requireEnsure = truereturn config};

After that npm i react-app-rewired to you app and change your build function in package.json to read react-app-rewired build/react-app-rewired start.That should do it for now.