title: Unable to display pdf file using react-pdf
body: <p>I am trying to load a pdf file into my project, but I am unable to see it. It just keeps showing 'Loading PDF...'</p>
  
  <p>I have added <code>pdfjs</code> web-worker as mentioned in some of their github repo issues, but still no change. I tried building the page by creating a new project suing <code>create-react-app</code> and it seems to be working fine. </p>
  
  <pre><code>import React, { PureComponent } from "react";
  import { Document, Page, pdfjs } from "react-pdf/dist/entry.webpack";
  import printJS from "print-js";
  
  import requiredFile from "./pdfdemo.pdf";
  
  
  pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${
    pdfjs.version
    }/pdf.worker.js`;
  
  export default class PdfViewer extends PureComponent {
    state = {
      numPages: null,
      pageNumber: 1,
      rotate: 0,
      scale: 1
    };
  
    onDocumentLoadSuccess = ({ numPages }) =&gt; {
      console.log('this function was triggered')
      this.setState({ numPages });
    };
  
    render() {
      const { pageNumber, numPages, scale, rotate } = this.state;
  
      return (
        &lt;React.Fragment&gt;
          &lt;div id="ResumeContainer"&gt;
            &lt;div style={{ width: 600 }}&gt;
              &lt;Document
                className="PDFDocument"
                file={requiredFile}
                onLoadError={(error) =&gt; {
                  console.log("Load error", error)
                }}
                onSourceSuccess={() =&gt; {
                  console.log("Source success")
                }}
                onSourceError={(error) =&gt; {
                  console.error("Source error", error)
                }}
                onLoadSuccess={this.onDocumentLoadSuccess}
              &gt;
                {window === undefined ? &lt;div&gt;nothing here&lt;/div&gt; : &lt;Page
                  pageNumber={pageNumber}
                  height={600}
                  className="PDFPage PDFPageOne"
                  scale={scale}
                /&gt;}
              &lt;/Document&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/React.Fragment&gt;
      );
    }
  }
  </code></pre>
  
  <p>The <code>onSourceSuccess</code> callback seems to be firing on console logging, but none of the other callbacks fire. In the console, I can see an error stating that the window is undefined.</p>