Alcumus / react-doc-viewer

Apache License 2.0
243 stars 103 forks source link

doc-nav previous n next not working #73

Open ZeemZach opened 3 years ago

ZeemZach commented 3 years ago

at initial 1st file of documents[] loads but after using doc-nav previous or next button. loader keeps on loading bcoz fetch request is not made to 2nd file

mattmogford-alcumus commented 3 years ago

Please could you provide an example of your code so that we can investigate further.

jojonarte commented 3 years ago

@mattmogford-alcumus I'm encountering the same problem, here's a sample code that replicates this problem, the first PDF gets loaded, however the next doesn't even load, it's just stuck in loading state. However if you have a file of different type from the first loaded file, it will get loaded.


import DocViewer, {
  DocViewerRenderers,
} from 'react-doc-viewer';

const Demo = () => {
  return (
   <DocViewer
        documents={[{
          uri: 'https://<PDFURLHERE>.pdf',
          fileType: 'pdf'
        }, {
          uri:  'https://<PDFURLHERE>.pdf',
          fileType: 'pdf'
        },
        {
         uri:  'https://<IMGURLHERE>.png', // this file gets loaded
         fileType: 'png' 
        }
        ]}
        pluginRenderers={DocViewerRenderers}
      />
  );
};
ZeemZach commented 3 years ago

Please could you provide an example of your code so that we can investigate further.

@mattmogford-alcumus - I have the same code structure as @jojonarte

jojonarte commented 3 years ago

@mattmogford I've been investigating, I could get it to work by adding the currentDocument dependency here https://github.com/Alcumus/react-doc-viewer/blob/fc604da9fb7de040d8799984797141c2482576ad/src/utils/useDocumentLoader.ts#L91

However it results in an unending amount of re-renders

jojonarte commented 3 years ago

adding currentFileNo seems to do the trick