rahul2104 / reactjs-pdf-reader

PDF Reader in browser for React js
MIT License
24 stars 11 forks source link

Fetch of the document not triggered if url props changed #3

Open LucDelp opened 4 years ago

LucDelp commented 4 years ago

Hello ! I'm currently facing an issue with this pdf reader. My pdf url changes according to a params of my component but even though its url props has been updated, the component doesn't fetch at the specified url. I'm maybe doing something wrong but I just can't see it.

image

I could not find any better module to display my pdfs in react so thank you for your job!

FabianoLothor commented 4 years ago

It's a bug, same problem here.

FabianoLothor commented 4 years ago

Cool!

@LucDelp try to add key={url} in your props.

FabianoLothor commented 4 years ago

Unbeautiful workaround:

...
  const [renderCounter, setRenderCounter] = useState(0);
...
  useEffect(() => {
    setRenderCounter(renderCounter + 1);
  }, [url]);
...
          <PDFReader
            key={renderCounter}
            url={url}
            ...
          />
...
nileshbhingaradiya commented 3 years ago

I just add a key with URL and it woke fine

<PDFReader key={url} url={url} ... />