Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the PDF doesn't rerender when scale change #5

Open
hpsaah opened this issue Apr 19, 2020 · 5 comments
Open

the PDF doesn't rerender when scale change #5

hpsaah opened this issue Apr 19, 2020 · 5 comments

Comments

@hpsaah
Copy link

hpsaah commented Apr 19, 2020

Hi i'am trying to use the component in another react component handling the scale at state but when i change it the pdf doesn't re-render

how can i fix it? i'am doing anything wrong or is a bug in the component?

thanks

@shaynethiessen
Copy link

This is a bug. I have the same problem.

@FabianoLothor
Copy link

@hpsaah try to add key={scale} in your props.

@FabianoLothor
Copy link

FabianoLothor commented Jul 6, 2020

Unbeautiful workaround:

...
  const [renderCounter, setRenderCounter] = useState(0);
...
  useEffect(() => {
    setRenderCounter(renderCounter + 1);
  }, [scale]);
...
          <PDFReader
            key={renderCounter}
            scale={scale}
            ...
          />
...

@hpsaah
Copy link
Author

hpsaah commented Jul 6, 2020

Thanks @FabianoLothor, changing the key property of the component you force to rerender

@shaynethiessen
Copy link

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants