title: Re-rendering issues when loading all pdf pages in "react-pdf"
body: <p>I am trying to load all the pages but it goes into infinate loop(basically re-rendering).
  <code>React.memo</code> is not helping me here.</p>
  <pre><code>const PdfRender = React.memo(({ pdfURL, pages, setPages }: any) =&gt; (
    &lt;Document
      file={{
        url: pdfURL,
      }}
      onLoadSuccess={(info) =&gt; {
        setPages(new Array(info._pdfInfo.numPages).fill(info._pdfInfo.numPages));
      }}
    &gt;
      {pages.map((_: any, i: number) =&gt; {
        return &lt;Page pageNumber={i + 1} /&gt;;
      })}
    &lt;/Document&gt;
  ));
  </code></pre>
  <p>I think, the re-rendering behaviour is logically correct because <code>onLoadSuccess</code> will get fire when the content is updated. As a result <code>setPages</code> and <code>pages</code> also get updated and <code>pages</code> re-renders the same pages again and <code>onLoadSuccess</code> will get fire again.(a loop basically)</p>
  <p>But there has be any solutions to this.</p>