yurydelendik / pdfjs-react

Simple example of using PDF.js components with React.
85 stars 38 forks source link

Why is using refs so important in getting actions to execute? #2

Closed daredevil82 closed 6 years ago

daredevil82 commented 6 years ago

Inside App.js, you defined a Viewer component that has a ref attribute:

<Viewer
        ref={(ref) => this.viewer = ref}
        ...
 />

and it is used when setting scale, zoom and PDF data on the Viewer component.

Could you share some details on why this is necessary? Are there possible alternatives? This seems very out of sync with the normal methods of state management with React, and I'm curious in regards to the why this is used.

Thanks!

yurydelendik commented 6 years ago

Could you share some details on why this is necessary?

To the the scale, zoom, etc.

Are there possible alternatives?

I don't know. Main point of this project is to show that it is possible to use PDF.js components with React. (The existing solutions provided by React gurus lacks that)

Closing as answered.